-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsource.py
More file actions
661 lines (548 loc) · 24.6 KB
/
source.py
File metadata and controls
661 lines (548 loc) · 24.6 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
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
import pygame
import pygame_gui
import time
import random
pygame.init()
WHITE = (255, 255, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)
BLUE = (0, 0, 255)
YELLOW = (255, 255, 0)
PURPLE = (128, 0, 128)
ORANGE = (255, 165, 0)
GRAY = (128, 128, 128)
BLACK = (0, 0, 0)
AQUA = (0, 255, 255)
ORANGE = (255, 105, 0)
WIDTH = 1000
HEIGHT = 800
window = pygame.display.set_mode((WIDTH, HEIGHT))
snake_block = 20
initsnake_speed = 10
snake_speed1 = 10
counter = 0
font_style = pygame.font.SysFont(None, 50)
score_font = pygame.font.SysFont(None, 35)
intro_style = pygame.font.SysFont(None, 100)
clock = pygame.time.Clock()
pygame.display.set_caption('Snake.io')
# Setting up pygame_gui
manager = pygame_gui.UIManager((WIDTH, HEIGHT))
play_button_classic = pygame_gui.elements.UIButton(relative_rect=pygame.Rect((WIDTH//3 - 50, HEIGHT//2 - 50), (150, 50)), text='Classic', manager=manager)
play_button_limited_moves = pygame_gui.elements.UIButton(relative_rect=pygame.Rect((WIDTH//3 - 50, HEIGHT//2 + 50), (150, 50)), text='Limited Moves', manager=manager)
play_button_multiplayer = pygame_gui.elements.UIButton(relative_rect=pygame.Rect((WIDTH//2 + 50, HEIGHT//2 - 50), (150, 50)), text='Multiplayer', manager=manager)
play_button_portal = pygame_gui.elements.UIButton(relative_rect=pygame.Rect((WIDTH//2 + 50, HEIGHT//2 + 50), (150, 50)), text='Portal', manager=manager)
play_button_survival = pygame_gui.elements.UIButton(relative_rect=pygame.Rect((WIDTH//2 - 75, HEIGHT//2 + 170), (150, 50)), text='Survival', manager=manager)
class Snake:
def __init__(self, x, y, color):
self.x_change = 0
self.y_change = 0
self.snake_list = []
self.snake_length = 1
self.x = x
self.y = y
self.color = color
self.start_time = None
self.moves = 0
def draw_snake(self):
for x in self.snake_list:
pygame.draw.rect(window, self.color, [x[0], x[1], snake_block, snake_block])
pygame.draw.rect(window, BLUE, [x[0], x[1], snake_block, snake_block], 2)
head = self.snake_list[-1]
pygame.draw.circle(window, RED, (head[0] + 5, head[1] + 5), 3)
pygame.draw.circle(window, RED, (head[0] + 15, head[1] + 5), 3)
def display_score(score, color):
score_text = font_style.render("Score: " + str(score), True, color)
window.blit(score_text, [10, 10])
def display_score2(score, color):
score_text = font_style.render("Score: " + str(score), True, color)
window.blit(score_text, [840, 10])
def display_moves(moves, color):
moves_text = font_style.render("Moves: " + str(moves), True, color)
window.blit(moves_text, [820, 10])
def display_intro(color): # Welcome to Snake.io
text = intro_style.render("Welcome to Snake.io ", True, color)
window.blit(text, [170, 170])
def message(msg, color): # Game over
mesg = font_style.render(msg, True, color)
window.blit(mesg, [WIDTH // 2 - 100, HEIGHT // 2 - 200])
# Generate food for limited moves mode
def generate_food_limited(food_number):
foods = []
for _ in range(food_number):
foodx = round(random.randrange(20, WIDTH - snake_block) / snake_block) * snake_block
foody = round(random.randrange(20, HEIGHT - snake_block) / snake_block) * snake_block
foods.append([foodx, foody])
return foods
# Draw food for limited moves mode
def draw_food_limited(foods):
for food in foods:
pygame.draw.rect(window, GREEN, [food[0], food[1], snake_block, snake_block])
# Game loop
def gameLoop(mode):
global counter
global snake_speed1
snake_speed1 = initsnake_speed
game_over = False
game_quit = False
snake1 = Snake(WIDTH // 2, HEIGHT // 2, YELLOW)
foodx = round(random.randrange(20, WIDTH - snake_block) / snake_block) * snake_block
foody = round(random.randrange(20, HEIGHT - snake_block) / snake_block) * snake_block
# Limited moves mode
if mode == 'limited_moves':
snake1.moves = 50 # Number of moves the snake can make
foods = generate_food_limited(200) # Generate 20 food items
display_moves(snake1.moves, ORANGE)
pygame.display.update()
while not game_quit:
while game_over:
window.fill(BLACK)
game_over_text = font_style.render("Game Over! Press Q-Quit or C-Play Again", True, BLUE)
window.blit(game_over_text, [WIDTH / 9, HEIGHT // 2])
display_score(snake1.snake_length - 1, RED)
pygame.display.update()
# Check for game quit or play again
for event in pygame.event.get():
if event.type == pygame.QUIT:
game_quit = True
game_over = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_q:
game_quit = True
game_over = False
if event.key == pygame.K_c:
mainMenuLoop()
for event in pygame.event.get():
if event.type == pygame.QUIT:
game_quit = True
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP:
snake1.y_change = -snake_block
snake1.x_change = 0
if mode == 'limited_moves':
snake1.moves -= 1
elif event.key == pygame.K_DOWN:
snake1.y_change = snake_block
snake1.x_change = 0
if mode == 'limited_moves':
snake1.moves -= 1
elif event.key == pygame.K_LEFT:
snake1.x_change = -snake_block
snake1.y_change = 0
if mode == 'limited_moves':
snake1.moves -= 1
elif event.key == pygame.K_RIGHT:
snake1.x_change = snake_block
snake1.y_change = 0
if mode == 'limited_moves':
snake1.moves -= 1
if counter % 100 == 0:
snake_speed1+=2
counter +=1
if counter == 100:
counter = 0
# Snake boundaries
if snake1.x >= WIDTH or snake1.x < 0 or snake1.y >= HEIGHT or snake1.y < 0:
game_over = True
snake1.x += snake1.x_change
snake1.y += snake1.y_change
window.fill(BLACK)
if mode == 'classic':
pygame.draw.rect(window, GREEN, [foodx, foody, snake_block, snake_block])
elif mode == 'limited_moves':
draw_food_limited(foods)
snake1.snake_list.append([snake1.x, snake1.y])
if len(snake1.snake_list) > snake1.snake_length:
del snake1.snake_list[0]
for pos in snake1.snake_list[:-1]:
if pos == [snake1.x, snake1.y]:
game_over = True
snake1.draw_snake()
display_score(snake1.snake_length - 1, RED)
if mode == 'limited_moves':
display_moves(snake1.moves, ORANGE)
pygame.display.update()
# Food consumption
if mode == 'classic':
if snake1.x == foodx and snake1.y == foody:
foodx = round(random.randrange(20, WIDTH - snake_block) / snake_block) * snake_block
foody = round(random.randrange(20, HEIGHT - snake_block) / snake_block) * snake_block
snake1.snake_length += 1
elif mode == 'limited_moves':
for food in foods:
if snake1.x == food[0] and snake1.y == food[1]:
foods.remove(food)
snake1.snake_length += 1
break
if mode == 'limited_moves' and snake1.moves <= 0:
game_over = True
clock.tick(snake_speed1)
pygame.quit()
quit()
# Multiplayer mode game loop
def gameLoopMultiplayer():
game_over1 = False
game_over2 = False
game_quit = False
snake1 = Snake(300, HEIGHT // 2, YELLOW)
snake2 = Snake(600, HEIGHT // 2, PURPLE)
foodx = round(random.randrange(20, WIDTH - snake_block) / snake_block) * snake_block
foody = round(random.randrange(20, HEIGHT - snake_block) / snake_block) * snake_block
food2x = round(random.randrange(20, WIDTH - snake_block) / snake_block) * snake_block
food2y = round(random.randrange(20, HEIGHT - snake_block) / snake_block) * snake_block
while not game_quit:
while game_over1:
window.fill(BLACK)
win_text = font_style.render("PURPLE WINS !", True, PURPLE)
window.blit(win_text, [WIDTH / 3, HEIGHT // 3])
game_over_text = font_style.render("Press Q-Quit or C-Play Again", True, GREEN)
window.blit(game_over_text, [WIDTH / 4, HEIGHT // 2])
display_score(snake1.snake_length - 1, YELLOW)
display_score2(snake2.snake_length - 1, PURPLE)
pygame.display.update()
# Check for game quit or play again
for event in pygame.event.get():
if event.type == pygame.QUIT:
game_quit = True
game_over1 = False
game_over2 = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_q:
game_quit = True
game_over1 = False
game_over2 = False
if event.key == pygame.K_c:
mainMenuLoop()
while game_over2:
window.fill(BLACK)
win_text = font_style.render("YELLOW WINS !", True, YELLOW)
window.blit(win_text, [WIDTH / 3, HEIGHT // 3])
game_over_text = font_style.render("Press Q-Quit or C-Play Again", True, GREEN)
window.blit(game_over_text, [WIDTH / 4, HEIGHT // 2])
display_score(snake1.snake_length - 1, YELLOW)
display_score2(snake2.snake_length - 1, PURPLE)
pygame.display.update()
# Check for game quit or play again
for event in pygame.event.get():
if event.type == pygame.QUIT:
game_quit = True
game_over1 = False
game_over2 = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_q:
game_quit = True
game_over1 = False
game_over2 = False
if event.key == pygame.K_c:
mainMenuLoop()
for event in pygame.event.get():
if event.type == pygame.QUIT:
game_quit = True
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP:
snake1.y_change = -snake_block
snake1.x_change = 0
elif event.key == pygame.K_DOWN:
snake1.y_change = snake_block
snake1.x_change = 0
elif event.key == pygame.K_LEFT:
snake1.x_change = -snake_block
snake1.y_change = 0
elif event.key == pygame.K_RIGHT:
snake1.x_change = snake_block
snake1.y_change = 0
elif event.key == pygame.K_w:
snake2.y_change = -snake_block
snake2.x_change = 0
elif event.key == pygame.K_s:
snake2.y_change = snake_block
snake2.x_change = 0
elif event.key == pygame.K_a:
snake2.x_change = -snake_block
snake2.y_change = 0
elif event.key == pygame.K_d:
snake2.x_change = snake_block
snake2.y_change = 0
# Snake boundaries
if snake1.x >= WIDTH or snake1.x < 0 or snake1.y >= HEIGHT or snake1.y < 0:
game_over1 = True
if snake2.x >= WIDTH or snake2.x < 0 or snake2.y >= HEIGHT or snake2.y < 0:
game_over2 = True
snake1.x += snake1.x_change
snake1.y += snake1.y_change
snake2.x += snake2.x_change
snake2.y += snake2.y_change
window.fill(BLACK)
pygame.draw.rect(window, GREEN, [foodx, foody, snake_block, snake_block])
pygame.draw.rect(window, RED, [food2x, food2y, snake_block, snake_block])
# Grow snake
snake1.snake_list.append([snake1.x, snake1.y])
snake2.snake_list.append([snake2.x, snake2.y])
while len(snake1.snake_list) > snake1.snake_length:
if len(snake1.snake_list) == 1:
game_over1 = True
break
else:
del snake1.snake_list[0]
while len(snake2.snake_list) > snake2.snake_length:
if len(snake2.snake_list) == 1:
game_over2 = True
break
else:
del snake2.snake_list[0]
for pos in snake1.snake_list[:-1]:
if pos == [snake1.x, snake1.y] or pos == [snake2.x, snake2.y]:
game_over1 = True
for pos in snake2.snake_list[:-1]:
if pos == [snake2.x, snake2.y] or pos == [snake1.x, snake1.y]:
game_over1 = True
snake1.draw_snake()
snake2.draw_snake()
display_score(snake1.snake_length - 1, YELLOW)
display_score2(snake2.snake_length - 1, PURPLE)
pygame.display.update()
# Food consumption
if snake1.x == foodx and snake1.y == foody:
foodx = round(random.randrange(20, WIDTH - snake_block) / snake_block) * snake_block
foody = round(random.randrange(20, HEIGHT - snake_block) / snake_block) * snake_block
snake1.snake_length += 1
if snake2.x == foodx and snake2.y == foody:
foodx = round(random.randrange(20, WIDTH - snake_block) / snake_block) * snake_block
foody = round(random.randrange(20, HEIGHT - snake_block) / snake_block) * snake_block
snake2.snake_length += 1
if snake1.x == food2x and snake1.y == food2y:
food2x = round(random.randrange(20, WIDTH - snake_block) / snake_block) * snake_block
food2y = round(random.randrange(20, HEIGHT - snake_block) / snake_block) * snake_block
snake1.snake_length -= 1
if snake2.x == food2x and snake2.y == food2y:
food2x = round(random.randrange(20, WIDTH - snake_block) / snake_block) * snake_block
food2y = round(random.randrange(20, HEIGHT - snake_block) / snake_block) * snake_block
snake2.snake_length -= 1
clock.tick(snake_speed1)
pygame.quit()
quit()
def gameLoopPortal():
game_quit = False
game_over = False
snake1 = Snake(WIDTH // 2, HEIGHT // 2, YELLOW)
foodx1 = round(random.randrange(0, WIDTH - snake_block) / snake_block) * snake_block
foody1 = round(random.randrange(0, HEIGHT - snake_block) / snake_block) * snake_block
foodx2 = round(random.randrange(0, WIDTH - snake_block) / snake_block) * snake_block
foody2 = round(random.randrange(0, HEIGHT - snake_block) / snake_block) * snake_block
while not game_quit:
while game_over:
window.fill(BLACK)
game_over_text = font_style.render("Game Over! Press Q-Quit or C-Play Again", True, BLUE)
window.blit(game_over_text, [WIDTH / 9, HEIGHT // 2])
display_score(snake1.snake_length - 1, RED)
pygame.display.update()
# Check for game quit or play again
for event in pygame.event.get():
if event.type == pygame.QUIT:
game_quit = True
game_over = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_q:
game_quit = True
game_over = False
if event.key == pygame.K_c:
mainMenuLoop()
for event in pygame.event.get():
if event.type == pygame.QUIT:
game_quit = True
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP:
snake1.y_change = -snake_block
snake1.x_change = 0
elif event.key == pygame.K_DOWN:
snake1.y_change = snake_block
snake1.x_change = 0
elif event.key == pygame.K_LEFT:
snake1.x_change = -snake_block
snake1.y_change = 0
elif event.key == pygame.K_RIGHT:
snake1.x_change = snake_block
snake1.y_change = 0
snake1.x += snake1.x_change
snake1.y += snake1.y_change
# Portal effect
if snake1.x == foodx1 and snake1.y == foody1:
snake1.x = foodx2
snake1.y = foody2
snake1.snake_length += 1
foodx1 = round(random.randrange(0, WIDTH - snake_block) / snake_block) * snake_block
foody1 = round(random.randrange(0, HEIGHT - snake_block) / snake_block) * snake_block
foodx2 = round(random.randrange(0, WIDTH - snake_block) / snake_block) * snake_block
foody2 = round(random.randrange(0, HEIGHT - snake_block) / snake_block) * snake_block
elif snake1.x == foodx2 and snake1.y == foody2:
snake1.x = foodx1
snake1.y = foody1
snake1.snake_length += 1
foodx1 = round(random.randrange(0, WIDTH - snake_block) / snake_block) * snake_block
foody1 = round(random.randrange(0, HEIGHT - snake_block) / snake_block) * snake_block
foodx2 = round(random.randrange(0, WIDTH - snake_block) / snake_block) * snake_block
foody2 = round(random.randrange(0, HEIGHT - snake_block) / snake_block) * snake_block
# Snake boundaries
if snake1.x >= WIDTH or snake1.x < 0 or snake1.y >= HEIGHT or snake1.y < 0:
game_over = True
window.fill(BLACK)
pygame.draw.rect(window, GREEN, [foodx1, foody1, snake_block, snake_block])
pygame.draw.rect(window, GREEN, [foodx2, foody2, snake_block, snake_block])
snake1.snake_list.append([snake1.x, snake1.y])
if len(snake1.snake_list) > snake1.snake_length:
del snake1.snake_list[0]
for pos in snake1.snake_list[:-1]:
if pos == [snake1.x, snake1.y]:
game_over = True
snake1.draw_snake()
display_score(snake1.snake_length - 1, RED)
pygame.display.update()
clock.tick(snake_speed1)
event1 = snake_speed1+10
pygame.time.set_timer(event1, 10)
pygame.quit()
quit()
class EnemySnake:
def __init__(self, x, y):
self.x = x
self.y = y
self.x_change = snake_block
self.y_change = 0
self.directions = [(snake_block, 0), (-snake_block, 0), (0, snake_block), (0, -snake_block)]
def move(self):
# Randomly change direction with a 1 in 20 chance
if random.randint(0, 20) == 0:
self.x_change, self.y_change = random.choice(self.directions)
self.x += self.x_change
self.y += self.y_change
# Wrap around screen boundaries
if self.x < 0:
self.x = WIDTH - snake_block
if self.x >= WIDTH:
self.x = 0
if self.y < 0:
self.y = HEIGHT - snake_block
if self.y >= HEIGHT:
self.y = 0
def draw(self):
pygame.draw.rect(window, RED, [self.x, self.y, snake_block, snake_block])
# Survival mode game loop
def gameLoopSurvival():
game_over = False
game_quit = False
start_ticks = pygame.time.get_ticks() # Starter tick
snake1 = Snake(WIDTH // 2, HEIGHT // 2, YELLOW)
enemies = [EnemySnake(random.randint(0, WIDTH // snake_block) * snake_block,
random.randint(0, HEIGHT // snake_block) * snake_block) for _ in range(3)]
foodx = round(random.randrange(0, WIDTH - snake_block) / snake_block) * snake_block
foody = round(random.randrange(0, HEIGHT - snake_block) / snake_block) * snake_block
while not game_quit:
while game_over:
window.fill(BLACK)
game_over_text = font_style.render("Game Over! Press Q-Quit or C-Play Again", True, BLUE)
window.blit(game_over_text, [WIDTH / 9, HEIGHT // 2])
display_score(snake1.snake_length - 1, RED)
pygame.display.update()
# Check for game quit or play again
for event in pygame.event.get():
if event.type == pygame.QUIT:
game_quit = True
game_over = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_q:
game_quit = True
game_over = False
if event.key == pygame.K_c:
mainMenuLoop()
for event in pygame.event.get():
if event.type == pygame.QUIT:
game_quit = True
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP:
snake1.y_change = -snake_block
snake1.x_change = 0
elif event.key == pygame.K_DOWN:
snake1.y_change = snake_block
snake1.x_change = 0
elif event.key == pygame.K_LEFT:
snake1.x_change = -snake_block
snake1.y_change = 0
elif event.key == pygame.K_RIGHT:
snake1.x_change = snake_block
snake1.y_change = 0
snake1.x += snake1.x_change
snake1.y += snake1.y_change
# Snake boundaries
if snake1.x >= WIDTH or snake1.x < 0 or snake1.y >= HEIGHT or snake1.y < 0:
game_over = True
window.fill(BLACK)
pygame.draw.rect(window, GREEN, [foodx, foody, snake_block, snake_block])
snake1.snake_list.append([snake1.x, snake1.y])
if len(snake1.snake_list) > snake1.snake_length:
del snake1.snake_list[0]
for pos in snake1.snake_list[:-1]:
if pos == [snake1.x, snake1.y]:
game_over = True
# Eat food
if snake1.x == foodx and snake1.y == foody:
foodx = round(random.randrange(0, WIDTH - snake_block) / snake_block) * snake_block
foody = round(random.randrange(0, HEIGHT - snake_block) / snake_block) * snake_block
snake1.snake_length += 1
# Draw and move enemy snakes
for enemy in enemies:
enemy.move()
enemy.draw()
if enemy.x == snake1.x and enemy.y == snake1.y:
game_over = True
# Check time and spawn new enemies every minute
seconds = (pygame.time.get_ticks() - start_ticks) / 1000
if seconds // 60 > len(enemies) - 3: # We started with 3 enemies
enemies.append(EnemySnake(random.randint(0, WIDTH // snake_block) * snake_block,
random.randint(0, HEIGHT // snake_block) * snake_block))
snake1.draw_snake()
display_score(snake1.snake_length - 1, RED)
pygame.display.update()
clock.tick(snake_speed1)
pygame.quit()
quit()
# Main menu loop
def mainMenuLoop():
running = True
# snake_speed1 = initsnake_speed
while running:
snake_speed1 = initsnake_speed
time_delta = clock.tick(60)/1000.0
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
if event.type == pygame.USEREVENT:
if event.user_type == pygame_gui.UI_BUTTON_PRESSED:
if event.ui_element == play_button_classic:
gameLoop('classic')
if event.ui_element == play_button_limited_moves:
gameLoop('limited_moves')
if event.ui_element == play_button_multiplayer:
gameLoopMultiplayer()
if event.ui_element == play_button_portal:
gameLoopPortal()
if event.ui_element == play_button_survival:
gameLoopSurvival()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_1:
gameLoop('classic')
if event.key == pygame.K_2:
gameLoop('limited_moves')
if event.key == pygame.K_3:
gameLoopMultiplayer()
if event.key == pygame.K_4:
gameLoopPortal()
if event.key == pygame.K_5:
gameLoopSurvival()
manager.process_events(event)
manager.update(time_delta)
window.fill(BLACK)
manager.draw_ui(window)
display_intro(YELLOW)
pygame.display.update()
mainMenuLoop()