--- /dev/null
+import math
+from collections.abc import Callable
+from pathlib import Path
+
+import pygame
+from mazegenerator import MazeGenerator
+from pygame import Vector2, Vector3
+
+from pacman.ecs import minimal_plugins
+from pacman.ecs.assets import Assets
+from pacman.ecs.coord import Coord2D, CoordAbs2D
+from pacman.ecs.graphics import ShouldRender, Sprite2D, graphics_plugins
+from pacman.ecs.hierarchy import ChildOf
+from pacman.ecs.schedule import StartupSchedule, UpdateSchedule
+from pacman.ecs.world import Component, Entity, Query, World
+
+
+class Maze(Component):
+ pass
+
+
+def create_maze(
+ world: World, assets: Assets[Sprite2D]
+) -> Callable[[MazeGenerator], Entity]:
+ def inner(maze: MazeGenerator) -> Entity:
+ root = world.spawn(
+ tuple[Maze, Coord2D, CoordAbs2D], (Maze(), Coord2D(), CoordAbs2D())
+ )
+ cell_paths = [
+ [f"./asset/walls/{cell}.png" for cell in line]
+ for line in maze.maze
+ ]
+ cell_dims = Vector3(64, 64, 0)
+ cells = [
+ (
+ ChildOf(root),
+ Coord2D(cell_dims.elementwise() * Vector3(x, y, 0)),
+ CoordAbs2D(),
+ assets.load(cell),
+ ShouldRender(),
+ )
+ for y, line in enumerate(cell_paths)
+ for x, cell in enumerate(line)
+ ]
+ world.spawn_many(
+ tuple[ChildOf, Coord2D, CoordAbs2D, Sprite2D, ShouldRender], cells
+ )
+ return root
+
+ return inner
+
+
+def setup_maze(world: World) -> None:
+ world.add_system(create_maze)(MazeGenerator())
+
+
+def move_maze(mazes: Query[Coord2D, Maze]) -> None:
+ tick = pygame.time.get_ticks()
+ for coord in mazes:
+ n = 400
+ coord.y = n + n * math.sin(tick / 100)
+
+
+def run_game() -> None:
+ World().with_plugins(graphics_plugins, minimal_plugins).with_systems(
+ StartupSchedule, setup_maze
+ ).run_main()