-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_pt_2_hellen.py
More file actions
365 lines (278 loc) · 10.1 KB
/
main_pt_2_hellen.py
File metadata and controls
365 lines (278 loc) · 10.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
import pygame
import random
import time
#from google import genai
import json
# GEMINI API FUNCTION #
# def fun(txt):
# response = client.models.generate_content(
# model="gemini-2.0-flash",
# contents=["generate 5 quiz questions based on this text and return questions and 4 multiple choice as a json file with questions named question and options named options and the answer named answer", txt],
# )
# text = response.text
# text = text[len("```json"):]
# text = text[:text.index("```")]
# data= json.loads(text)
# for i in data:
# response = client.models.generate_content(
# model="gemini-2.0-flash",
# contents=["can you return a sentence directly from this text that contains the answer to" + i['question'],txt]
# )
# i["highlight"] = response.text
# return data
# text = "One of the first organisms that humans domesticated was yeast. In 2011, while excavating an old graveyard in an Armenian cave, scientists discovered a 6,000 year-old winery, complete with a wine press, fermentation vessels, and even drinking cups. This winery was a major technological innovation that required understanding how to control Sacharomyces, the genus of yeast used in alcohol and bread production."
pygame.init()
pygame.mixer.init()
# GEMINI TEXT BOX #
user_text = ""
texts = ""
box_color_active = pygame.Color('lightskyblue3')
box_color_inactive = pygame.Color('gray15')
box_color = box_color_inactive
# COLORS #
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (129, 167, 144)
DARK_GREEN = (36,130,72)
RED = (255, 0, 0)
# LOADING IMAGES FOR SPRITES AND BACKGROUND #
window_size = (1100, 700)
display = pygame.display.set_mode(window_size)
bg_image = pygame.image.load('final_sprites/forest_background_bigger.png')
bg_image = pygame.transform.scale(bg_image, window_size)
bg_image_grey = pygame.image.load('final_sprites/forest_background_grey.png')
bg_image_grey = pygame.transform.scale(bg_image_grey, window_size)
title_cloud = pygame.image.load('final_sprites/knowlege_quest_cloud.png')
title_cloud = pygame.transform.scale(title_cloud, (1000, 700))
battle_cloud = pygame.image.load('battle_begins_cloud.png')
battle_cloud = pygame.transform.scale(battle_cloud, (1000, 700))
choose_cloud = pygame.image.load('choose_fighter_cloud.png')
choose_cloud = pygame.transform.scale(choose_cloud, (1000, 700))
you_win_cloud = pygame.image.load('you_win_cloud.png')
you_win_cloud = pygame.transform.scale(you_win_cloud, (1000, 700))
you_lose_cloud = pygame.image.load('you_lose_cloud.png')
you_lose_cloud = pygame.transform.scale(you_lose_cloud, (1000, 700))
button_image = pygame.image.load('final_sprites/button2.png')
button_image = pygame.transform.scale(button_image, (200, 70))
hover_button_image = pygame.image.load('final_sprites/hover_button.png')
hover_button_image = pygame.transform.scale(hover_button_image, (200, 70))
empty_cloud = pygame.image.load('final_sprites/cloud.png')
empty_cloud = pygame.transform.scale(empty_cloud, (700, 500))
earth_dino = pygame.image.load('final_sprites/earthDino.png')
earth_dino = pygame.transform.scale(earth_dino, (100, 100))
fire_dino = pygame.image.load('final_sprites/fireDino.png')
fire_dino = pygame.transform.scale(fire_dino, (100, 100))
air_dino = pygame.image.load('final_sprites/airDino.png')
air_dino = pygame.transform.scale(air_dino, (100, 100))
water_dino = pygame.image.load('final_sprites/waterDino.png')
water_dino = pygame.transform.scale(water_dino, (100, 100))
incorrect_sprite = pygame.image.load('final_sprites/ermActually.png')
incorrect_sprite = pygame.transform.scale(incorrect_sprite, (100, 100))
correct_sprite = pygame.image.load('final_sprites/happy.png')
correct_sprite = pygame.transform.scale(correct_sprite, (100, 100))
meatball = pygame.image.load('final_sprites/meatball.png')
meatball = pygame.transform.scale(meatball, (100, 100))
tornado = pygame.image.load('final_sprites/tornado.png')
tornado = pygame.transform.scale(tornado, (100, 100))
bees = pygame.image.load('final_sprites/bees.png')
bees = pygame.transform.scale(bees, (100, 100))
bubbles = pygame.image.load('final_sprites/bubbles.png')
bubbles = pygame.transform.scale(bubbles, (100, 100))
# PAGE STATES #
HOME_SCREEN = 0
HOME_SCREEN_2 = 1
INFO = 3
UPLOAD = 4
GENERATING_QUESTIONS = 5
CHOOSE_FIGHTER = 6
BATTLE_BEGINS = 7
QUESTION = 8
ANS_RESULT = 9
ATTACK = 10
REVIEW_TEXT = 11
GAME_OVER = 12
STATS = 13
current_page = BATTLE_BEGINS
# BUTTONS #
#HOME SCREEN
upload_text_button_rect = button_image.get_rect()
upload_text_button_rect.topleft = (450, 400)
info_button_rect = button_image.get_rect()
info_button_rect.topleft = (450, 500)
begin_button_rect = button_image.get_rect()
begin_button_rect.topleft = (450, 400)
#INFO
close_button_rect = button_image.get_rect()
close_button_rect.topleft = (600, 400)
#UPLOAD
done_upload_button_rect = button_image.get_rect()
done_upload_button_rect.topleft = (700, 400)
#CHOOSE FIGHTER
left_button_rect = button_image.get_rect()
left_button_rect.topleft = (600, 400)
right_button_rect = button_image.get_rect()
right_button_rect.topleft = (500, 400)
continue_fighter_button_rect = button_image.get_rect()
continue_fighter_button_rect.topleft = (400, 400)
#BATTLE BEGINS
continue_battle_button_rect = button_image.get_rect()
continue_battle_button_rect.topleft = (300, 400)
#QUESTION
done_question_button_rect = button_image.get_rect()
done_question_button_rect.topleft = (300, 500)
#ANS_RESULT
done_result_button_rect = button_image.get_rect()
done_result_button_rect.topleft = (300, 600)
#YOU ATTACK
continue_attack_button_rect = button_image.get_rect()
continue_attack_button_rect.topleft = (300, 500)
#REVIEW TEXT
done_review_button_rect = button_image.get_rect()
done_review_button_rect.topleft = (400, 400)
#GAME OVER
stats_button_rect = button_image.get_rect()
stats_button_rect.topleft = (500, 400)
play_again_button_rect = button_image.get_rect()
play_again_button_rect.topleft = (600, 400)
#STATS
done_stats_button_rect = button_image.get_rect()
done_stats_button_rect.topleft = (700, 400)
button_size = upload_text_button_rect.size
# ANSWER CHOICE CLASS #
class AnswerChoice:
@property
def name(self):
return self._name
#
@name.setter
def name(self, value):
self._name = value
@property
def correct(self):
return self._correct
#
@correct.setter
def correct(self, value):
self._correct = value
@property
def button(self):
return self._button
#
@button.setter
def button(self, value):
self._button = value
# GAMEPLAY VARIABLES #
choice_correct = AnswerChoice()
choice_wrong_1 = AnswerChoice()
choice_wrong_2 = AnswerChoice()
choice_wrong_3 = AnswerChoice()
max_rounds = 5
turns = 0
global score
score = 0
correct_ans = True
answer_processed = False
uploaded = False
# PAGE DRAWING METHODS #
def draw_home_screen():
display.blit(bg_image, (0, 0))
display.blit(title_cloud, (75, 15))
mouse_pos = pygame.mouse.get_pos()
font = pygame.font.Font(None, 36)
if uploaded:
if begin_button_rect.collidepoint(mouse_pos):
display.blit(hover_button_image, begin_button_rect)
else:
display.blit(button_image, begin_button_rect)
begin_text = font.render("Begin", True, BLACK)
begin_text_rect = begin_text.get_rect(center=begin_button_rect.center)
display.blit(begin_text, begin_text_rect)
else:
if upload_text_button_rect.collidepoint(mouse_pos):
display.blit(hover_button_image, upload_text_button_rect)
else:
display.blit(button_image, upload_text_button_rect)
# Draw button text
font = pygame.font.Font(None, 36)
text = font.render("Upload Text", True, BLACK)
text_rect = text.get_rect(center=upload_text_button_rect.center)
display.blit(text, text_rect)
if info_button_rect.collidepoint(mouse_pos):
display.blit(hover_button_image, info_button_rect)
else:
display.blit(button_image, info_button_rect)
# Draw button text
text_info = font.render("Info", True, BLACK)
text_info_rect = text_info.get_rect(center=info_button_rect.center)
display.blit(text_info, text_info_rect)
def draw_info():
pass
def draw_upload():
pass
def draw_home_screen_2():
pass
def draw_generating_questions():
pass
def draw_choose_fighter():
pass
def draw_battle_begins():
display.blit(bg_image, (0, 0))
display.blit(battle_cloud, (75, 15))
mouse_pos = pygame.mouse.get_pos()
font = pygame.font.Font(None, 36)
if continue_battle_button_rect.collidepoint(mouse_pos):
display.blit(hover_button_image, continue_battle_button_rect)
else:
display.blit(button_image, continue_battle_button_rect)
# Draw button text
text_info = font.render("Continue", True, BLACK)
text_info_rect = text_info.get_rect(center=info_button_rect.center)
display.blit(text_info, text_info_rect)
def draw_question():
pass
def draw_result():
pass
def draw_attack():
pass
def draw_review():
pass
def draw_game_over():
pass
def draw_stats():
pass
# MAIN LOOP #
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
#if other
if current_page == HOME_SCREEN:
draw_home_screen()
elif current_page == INFO:
draw_info()
elif current_page == UPLOAD:
draw_upload()
elif current_page == HOME_SCREEN_2:
draw_home_screen_2()
elif current_page == GENERATING_QUESTIONS:
draw_generating_questions()
elif current_page == CHOOSE_FIGHTER:
draw_choose_fighter()
elif current_page == BATTLE_BEGINS:
draw_battle_begins()
elif current_page == QUESTION:
draw_question() #
elif current_page == ANS_RESULT:
draw_result()
elif current_page == ATTACK:
draw_attack() #need status of who was correct last
elif current_page == REVIEW_TEXT:
draw_review()
elif current_page == GAME_OVER:
draw_game_over()
elif current_page == STATS:
draw_stats()
pygame.display.flip()
# Quit pygame
pygame.quit()