game.Game.__init__()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 12
rs 10
c 0
b 0
f 0
cc 1
nop 1
1
import pygame
2
3
from src.utils import load_texture
4
5
6
ICON_PATH: str = "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