-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
100 lines (78 loc) · 2.69 KB
/
main.py
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
import sys
import pygame as pg
from pause import Pause
from settings import FPS, HEIGHT, WIDTH
from arena import Arena
from mainmenu import MainMenu
from cutscene import cutscene1, cutscene2, cutscene3, mapselection
class Game:
def __init__(self) -> None:
pg.init()
pg.display.set_caption("Scribbles vs. Sketches")
self.screen = pg.display.set_mode((WIDTH, HEIGHT))
self.clock = pg.time.Clock()
self.mainmenu = MainMenu(self.screen, self.clock)
self.mainmenu.draw()
self.mainmenu.play()
# game selection
self.map_selection = mapselection()
self.map_selection.play()
self.cutscene1 = cutscene1()
self.cutscene2 = cutscene2()
self.cutscene3 = cutscene3()
self.cutscene1.play()
self.cutscene2.play()
self.cutscene3.play()
self.game_type = 3
pg.mixer.music.load("sounds/epic_music.mp3")
pg.mixer.music.play(-1)
self.arena = Arena(self.game_type, self.map_selection.level_idx)
self.is_paused = False
self.pause_menu = Pause(self.screen)
def return_menu(self):
pg.mixer.music.stop()
self.mainmenu = MainMenu(self.screen, self.clock)
self.is_paused = False
self.mainmenu.draw()
self.mainmenu.play()
self.map_selection = mapselection()
self.map_selection.play()
pg.mixer.music.load("sounds/epic_music.mp3")
pg.mixer.music.play(-1)
self.arena = Arena(self.game_type, self.map_selection.level_idx)
def draw_pause(self):
"""Pause the game."""
self.pause_menu.draw()
res = self.pause_menu.update()
if res == "quit":
pg.quit()
sys.exit()
elif res == "resume":
self.is_paused = False
elif res == "main_menu":
self.return_menu()
elif res == "options":
print("options") # TODO: Make this a trolling
def run(self):
"""Main game loop."""
while True:
for event in pg.event.get():
if event.type == pg.QUIT:
pg.quit()
sys.exit()
if event.type == pg.KEYDOWN:
if event.key == pg.K_ESCAPE or event.key == pg.K_p:
self.is_paused = not self.is_paused
pg.display.update()
if self.is_paused:
self.draw_pause()
continue
self.screen.fill("black")
if self.arena.game_end:
self.return_menu()
else:
self.arena.run()
self.clock.tick(FPS)
if __name__ == "__main__":
game = Game()
game.run()