From: Thomas Rimelen Date: Mon, 12 Oct 2026 10:31:42 +0000 (+0200) Subject: add timer X-Git-Url: https://git.uwuaxy.net/Project%20Management.png?a=commitdiff_plain;h=a1e2222a90bd90449386a9b9865563abd4adb32d;p=axy%2Fft%2Fpacman.git add timer --- diff --git a/src/pacman/game/__init__.py b/src/pacman/game/__init__.py index 59805a2..8ab73dc 100644 --- a/src/pacman/game/__init__.py +++ b/src/pacman/game/__init__.py @@ -216,7 +216,7 @@ def create_maze( root_maze = Maze(len(maze.maze[0]), len(maze.maze)) root = world.spawn( tuple[Maze, CoordBundle], - (root_maze, CoordBundle()), + (root_maze, CoordBundle(100, 100)), ) cell_dims = Vector2(64, 64) cells = { @@ -240,6 +240,9 @@ def create_maze( return inner + + + def spawn_superpacgums( world: World, mazes: Query[Maze], assets: Assets[Sprite2D] ) -> None: @@ -798,6 +801,11 @@ def print_lives(state: GameState) -> str: return f"Lives: {state.lives}" +def print_timer(state: GameState, config: Config) -> str: + time = config.level_timer - state.timer + return f"{time // 60}" + + def setup_text(world: World, fonts: Assets[Font]) -> None: world.spawn_many( tuple[CoordBundle, ShouldRender, ComputedText, TextDisplay], @@ -820,6 +828,15 @@ def setup_text(world: World, fonts: Assets[Font]) -> None: fonts.load("./asset/fonts/JetBrainsMonoNL-Regular.ttf:30"), ), ), + ( + CoordBundle(y=200, depth=-20), + ShouldRender(), + ComputedText(print_timer), + TextDisplay( + "", + fonts.load("./asset/fonts/JetBrainsMonoNL-Regular.ttf:30"), + ), + ), ], )