game   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 26
dl 0
loc 42
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A Game.__init__() 0 12 1
A Game.update() 0 3 1
A Game.main() 0 9 3
A Game.handle_event() 0 4 2
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