-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·37 lines (32 loc) · 932 Bytes
/
Copy pathmain.py
File metadata and controls
executable file
·37 lines (32 loc) · 932 Bytes
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
from config import *
import time
import screens
class Game:
def __init__(self):
self.clock = pygame.time.Clock()
pygame.display.set_caption(TITLE)
self.window = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT))
self.screen = screens.MenuScreen(self)
self.music = pygame.mixer.Sound('./src/audios/music.ogg')
self.music.set_volume(.75)
self.music.play(-1)
def run(self):
while True:
INPUT.reset()
for event in pygame.event.get():
if event.type == pygame.QUIT:
if isinstance(self.screen, screens.LevelScreen):
save_game({'level_number': self.screen.level_number}, './src/save.txt')
return
INPUT.process_input(event)
self.window.fill(BG_COLOR)
self.screen.update()
self.screen.draw(self.window)
self.window.blit(SCREEN_FADER, (0, 0))
pygame.display.update()
self.clock.tick(FPS)
if __name__ == '__main__':
game = Game()
game.run()
pygame.quit()
sys.exit()