]> Untitled Git - axy/ft/pacman.git/commitdiff
Building, makefile improvements, partial readme, and refactor
authorAxy <gilliardmarthey.axel@gmail.com>
Thu, 22 Oct 2026 22:12:08 +0000 (00:12 +0200)
committerAxy <gilliardmarthey.axel@gmail.com>
Thu, 22 Oct 2026 22:12:08 +0000 (00:12 +0200)
.gitignore
Makefile
README.md
requirements.txt [new file with mode: 0644]
src/pacman/game/__init__.py

index eed60d30463f01a29676c5b7dbc8979aa7a49dc5..858b83f53c0af6f0313b27b6c6c5054e1a434361 100644 (file)
@@ -8,4 +8,4 @@ a.txt
 **/__pycache__
 .mypy_cache
 .ruff_cache
-dist/
+/pacman
index 824a78f30f0f66047273e21c423a7501148a3f83..ff0e902f3d6b0380d05bd8cbed89344ee61a2b77 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,6 @@ clean:
        find . -type d -name ".mypy_cache" -exec rm -r {} +
        find . -type d -name ".ruff_cache" -exec rm -r {} +
        find . -type d -name "*.pyc" -delete
-#      @rm -rf .venv
 
 lint:
        uv run flake8 src
@@ -37,4 +36,5 @@ check:
        uv run ty check
 
 build:
-       uv build
+       uv pip compile pyproject.toml -o requirements.txt
+       uv run shiv -o pacman -e pacman:main -r requirements.txt .
index f541daaeedf44b696364fd3901c81b79b8891006..09edb8d271baecd8f1c809b1148195ea2ec98b61 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1 +1,80 @@
 *This project has been created as part of the 42 curriculum by agilliar and trimelen*
+
+# Description
+
+`pacman` is a simple 2d arcade game made in python.
+It was implemented using a custom ECS engine, and pygame as a rendering frontend.
+
+# Instructions
+
+`uv` is required to run or build the program.
+
+It can simply be built with
+```bash
+uv run pacman ./config.json
+```
+It can also be built with
+```bash
+make build
+```
+followed by
+```bash
+./pacman ./config.json
+```
+
+`pacman` must be given a json config file to run.
+
+# Resources
+
+TODO
+
+# Configuration
+
+TODO
+
+# Highscore
+
+The highscore is a simple json file written to when changed. Only one highscore per name.
+
+# Maze Generation
+
+The mazegen api is simply installed through the wheel, and called to generate the maze.
+
+# Implementation
+
+An ECS engine was used, as it is generally very effective at expressing game logic.
+No already existing python ECS engine was adequately featured, so a custom one was made, with features including:
+* Archetypal querying
+* Complex scheduling
+* System argument extraction based on type hints
+* Component hooks
+Pygame was used as a very simple rendering backend within the ECS, making for very reusable code for other game applications.
+Thanks to ECS, the core game logic was straightforwardly implemented with little thought required for rendering or asset loading once they were implemented in engine.
+
+# General Software Architecture
+
+The whole engine is centered around the `ecs` module:
+The `World` centralizes all the data and behavior. It schedules `System`s, ordered on a `DAG`.
+`System`s are function whose arguments may be extracted from a `World`, like a `Query` or `Resource`.
+The `World` stores its data on `Entity`s, as `Component`s, which may be later queried.
+`ComponentHook`s are used to get notified when changes occur for specific types.
+The `World` may extend its behavior through `Plugin`s.
+
+`Entity`s support hierarchy through the `ChildOf` and `Children` component, whose invariants are maintained through `ComponentHooks`.
+The hierarchy (queriable through `Hierarchy`) is, among other things, used to update children coordinates and depth relative to their parents.
+
+`Asset`s are managed in the `ecs.assets` module, allowing for caching stored in `Resouce`s.
+
+The `gui` module allows for text rendering and basic layout operations, such as `Window` relative positionning.
+
+The rendering and input management is done very simply through a single `Plugin`, `ecs.graphics`, bridging between `pygame` and the ECS.
+
+The general game logic is then implemented on top of that in a single `game` module containing all desired behavior.
+This includes `Maze` generation through the provided `mazegen` library, `Ghost` pathing, `GameState`, menus, etc.
+
+The whole is packaged as an executable for distribution using `shiv`.
+
+
+# Project Management
+
+TODO
diff --git a/requirements.txt b/requirements.txt
new file mode 100644 (file)
index 0000000..0610ff7
--- /dev/null
@@ -0,0 +1,19 @@
+# This file was autogenerated by uv via the following command:
+#    uv pip compile pyproject.toml -o requirements.txt
+annotated-types==0.8.0
+    # via pydantic
+mazegenerator-2.0.2-py3-none-any.whl
+    # via pacman (pyproject.toml)
+pydantic==2.14.1
+    # via pacman (pyproject.toml)
+pydantic-core==2.50.1
+    # via pydantic
+pygame==2.6.1
+    # via pacman (pyproject.toml)
+typing-extensions==4.16.0
+    # via
+    #   pydantic
+    #   pydantic-core
+    #   typing-inspection
+typing-inspection==0.4.4
+    # via pydantic
index ceff113110a0b58fcf0ba041f65c559899114f08..e23322ee7ba86c88c72ae5a7cd3ecf6a80d59d9a 100644 (file)
@@ -151,8 +151,6 @@ class Highscores(Resource, BaseModel):
 class GameIsOver(Resource):
     """Resource set when game is over."""
 
-    pass
-
 
 @dataclass
 class PlayerName(Resource):
@@ -175,44 +173,30 @@ class GameState(Resource):
 class CheatMode(Component):
     """Component for the cheat mod."""
 
-    pass
-
 
 class MainMenu(Component):
     """Component for main menu items."""
 
-    pass
-
 
 class GameMenu(Component):
     """Component for game menu items."""
 
-    pass
-
 
 class GameOver(Component):
     """Component for game menu items."""
 
-    pass
-
 
 class GameGui(Component):
     """Component for game graphical user interface items."""
 
-    pass
-
 
 class PacGum(Component):
     """Component for pacgums items."""
 
-    pass
-
 
 class SuperPacGum(Component):
     """Component for super pacgums items."""
 
-    pass
-
 
 @dataclass
 class Pacman(Component):