-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
48 lines (37 loc) · 1.19 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
import pygame
from scenes.game import GameScene
from scenes.main_menu import MainMenu
import const
if __name__ == "__main__":
# Initialize Pygame
pygame.init()
# Set up the screen
screen = pygame.display.set_mode(const.SCREEN_SIZE)
pygame.display.set_caption("Pacman Game")
# Scenes
current_scene = main_menu = MainMenu()
game = GameScene()
clock = pygame.time.Clock()
# Game loop
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.KEYDOWN:
if current_scene == main_menu:
if event.key == pygame.K_RETURN:
current_scene = game
elif event.key == pygame.K_q:
running = False
if current_scene == game:
game.handle_events(event)
if current_scene == main_menu:
main_menu.draw(screen)
else:
game.update()
game.draw(screen)
game.frame += 1
fps = clock.get_fps()
clock.tick(60)
pygame.quit()