]> Untitled Git - axy/ft/pacman.git/commitdiff
add timer
authorThomas Rimelen <trimelen@k1r1p10.42mulhouse.fr>
Mon, 12 Oct 2026 10:31:42 +0000 (12:31 +0200)
committerThomas Rimelen <trimelen@k1r1p10.42mulhouse.fr>
Mon, 12 Oct 2026 10:31:42 +0000 (12:31 +0200)
src/pacman/game/__init__.py

index 59805a27c4b8123e8a2d063a186d6df0f6a1920c..8ab73dc61bb37dd98bcecde9fda502b404529b55 100644 (file)
@@ -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"),
+                ),
+            ),
         ],
     )