-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
42 lines (32 loc) · 1.09 KB
/
Copy pathmain.py
File metadata and controls
42 lines (32 loc) · 1.09 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
import pygame
pygame.init()
from sys import exit
from time import time
from src.config import Config
from src.global_state import GlobalState
from src.components.status import GameStatus
from src.game_phases import main_menu_phase, gameplay_phase, end_menu_phase
from src.services.draw_cursor import DrawCursor
FramePerSec = pygame.time.Clock()
def update_game_display():
pygame.display.update()
FramePerSec.tick(Config.FPS)
def main():
while True:
fps = time()
events = pygame.event.get()
if GlobalState.GAME_STATE == GameStatus.MAIN_MENU:
main_menu_phase(events)
elif GlobalState.GAME_STATE == GameStatus.GAMEPLAY:
gameplay_phase(events)
elif GlobalState.GAME_STATE == GameStatus.GAME_END:
end_menu_phase(events)
DrawCursor(GlobalState.SCREEN)
for event in events:
if(event.type == pygame.QUIT):
pygame.quit()
exit()
update_game_display()
pygame.display.set_caption(str(int(1/(time()-fps))))
if __name__ == "__main__":
main()