| Total Complexity | 7 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import pygame |
||
| 2 | |||
| 3 | from src.utils import load_texture |
||
| 4 | |||
| 5 | |||
| 6 | ICON_PATH: str = f"icon/icon.ico" |
||
| 7 | |||
| 8 | |||
| 9 | class Game: |
||
| 10 | |||
| 11 | def __init__(self): |
||
| 12 | self.height = 1280 |
||
| 13 | self.width = 720 |
||
| 14 | |||
| 15 | self.screen = pygame.display.set_mode((self.height, self.width)) |
||
| 16 | self.clock = pygame.time.Clock() |
||
| 17 | |||
| 18 | pygame.display.set_icon(load_texture(ICON_PATH)) |
||
| 19 | |||
| 20 | self.is_running = False |
||
| 21 | |||
| 22 | self.max_fps = 60 |
||
| 23 | |||
| 24 | def main(self) -> None: |
||
| 25 | """Game entry point.""" |
||
| 26 | self.is_running = True |
||
| 27 | |||
| 28 | while self.is_running: |
||
| 29 | self.update() |
||
| 30 | |||
| 31 | for event in pygame.event.get(): |
||
| 32 | self.handle_event(event) |
||
| 33 | |||
| 34 | def handle_event(self, event): |
||
| 35 | if event.type == pygame.QUIT: |
||
| 36 | self.is_running = False |
||
| 37 | return |
||
| 38 | |||
| 39 | def update(self): |
||
| 40 | pygame.display.update() |
||
| 41 | self.clock.tick(self.max_fps) |
||
| 42 |