Game.__init__ aufgeräumt und kommentiert.
This commit is contained in:
parent
e17c55fbcf
commit
e3c70182fb
1 changed files with 6 additions and 14 deletions
20
game.py
20
game.py
|
|
@ -6,39 +6,31 @@ SCREEN_HEIGHT = 720
|
||||||
|
|
||||||
class Game:
|
class Game:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
# Pygame setup
|
||||||
pygame.init()
|
pygame.init()
|
||||||
|
|
||||||
pygame.display.set_caption("School Game")
|
pygame.display.set_caption("School Game")
|
||||||
|
|
||||||
self.clock = pygame.Clock()
|
self.clock = pygame.Clock()
|
||||||
|
# Surfaces
|
||||||
self.screen: pygame.Surface = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
|
self.screen: pygame.Surface = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
|
||||||
|
|
||||||
self.display: pygame.Surface = pygame.Surface((self.screen.get_width() // 2, self.screen.get_height() // 2))
|
self.display: pygame.Surface = pygame.Surface((self.screen.get_width() // 2, self.screen.get_height() // 2))
|
||||||
|
# Pygame-Variablen
|
||||||
self.running: bool = True
|
self.running: bool = True
|
||||||
|
|
||||||
self.dt: int = 0
|
self.dt: int = 0
|
||||||
|
# Spieler
|
||||||
self.player_pos = pygame.Vector2(self.display.get_width() / 2, self.display.get_height() / 2)
|
self.player_pos = pygame.Vector2(self.display.get_width() / 2, self.display.get_height() / 2)
|
||||||
self.player_width = 20
|
self.player_width = 20
|
||||||
self.player_height = 20
|
self.player_height = 20
|
||||||
|
|
||||||
self.player = Player(self, self.player_pos, width=self.player_width, height=self.player_height)
|
self.player = Player(self, self.player_pos, width=self.player_width, height=self.player_height)
|
||||||
|
# Items
|
||||||
self.item_rect = pygame.Rect(70, 150, 10, 10)
|
self.item_rect = pygame.Rect(70, 150, 10, 10)
|
||||||
|
|
||||||
self.flashlight = 0
|
self.flashlight = 0
|
||||||
self.flashlight_rect = pygame.Rect(0, 0, 0, 0)
|
self.flashlight_rect = pygame.Rect(0, 0, 0, 0)
|
||||||
|
|
||||||
self.color_item = (0, 0, 0)
|
self.color_item = (0, 0, 0)
|
||||||
|
|
||||||
self.light_points: list[pygame.Vector2] = []
|
self.light_points: list[pygame.Vector2] = []
|
||||||
|
# Level
|
||||||
self.walls = [pygame.Rect(100, 100, 20, 50), pygame.Rect(300, 300, 200, 20), pygame.Rect(550, 80, 20, 200)]
|
self.walls = [pygame.Rect(100, 100, 20, 50), pygame.Rect(300, 300, 200, 20), pygame.Rect(550, 80, 20, 200)]
|
||||||
self.light_radius = 75
|
self.light_radius = 75
|
||||||
|
|
||||||
# self.circle = pygame.geometry.Circle(self.player_pos[0], self.player_pos[1], 30)
|
|
||||||
|
|
||||||
def run(self) -> None:
|
def run(self) -> None:
|
||||||
while self.running:
|
while self.running:
|
||||||
self.dt: float = self.clock.tick(60) / 1000.0
|
self.dt: float = self.clock.tick(60) / 1000.0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue