würfel läuft

This commit is contained in:
kreischeran103444 committed 2026-11-05 01:25:22 +01:00
commit 3cc07d2575
13 files changed
+526

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
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
if running:
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