mond läuft

This commit is contained in:
kreischeran103444 committed 2026-10-22 12:55:07 +02:00
1 parent f36985221b
commit e02b552da3
4 files changed
+125 -61

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
import pygame
class Game:
"""Basic Pygame game loop.
Subclasses **must** implement:
* ``update_game`` – update state, return ``False`` to quit.
* ``draw_game`` – render to the screen.
"""
def __init__(self, title: str, fps: int, size: tuple[int, int]):
pygame.init()
self.screen = pygame.display.set_mode(size)
pygame.display.set_caption(title)
self.clock = pygame.time.Clock()
self.fps = fps
self.size = size
def run(self) -> None:
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
running = self.update_game()
self.draw_game()
pygame.display.flip()
self.clock.tick(self.fps)
pygame.quit()
def update_game(self) -> bool:
raise NotImplementedError
def draw_game(self) -> None:
raise NotImplementedError