-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
46 lines (34 loc) · 950 Bytes
/
run.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
import pygame
from menu.menu import Menu
from game import Game
from settings import SCREEN_WIDTH, SCREEN_HEIGHT
def main():
pygame.init()
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption("Pong")
clock = pygame.time.Clock()
STATE = {
'in_menu': True,
}
game = Game(screen)
menu = Menu(screen)
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if STATE['in_menu']:
menu.handle_events(event, game, STATE)
else:
game.handle_events(event, STATE)
if STATE['in_menu']:
menu.update()
menu.render()
else:
game.update()
game.render()
pygame.display.flip()
clock.tick(60)
pygame.quit()
if __name__ == "__main__":
main()