How hamzalaaz/pac-man works
Pac-Man is a Python arcade game whose main workflow runs from configuration and menu selection through generated levels, player/ghost gameplay, and a win or game-over screen. The game loop in src/start.py coordinates screen transitions and level progression; gameplay includes maze generation, collectible items, entity movement, ghost AI, scoring, and cheat controls. UI screens also provide instructions, pause, and highscore views. The README documents some behavior whose implementation excerpts were not shown, so those relationships are included only where documented or indexed.
Main entry points: start.py Game loop · game_screen.py Level gameplay · text.py Text drawer · end_screen.py End screen
Components 17
Game runtime
- Game loop
src/start.py - MLX window
src/screens/mlx_class.py
Gameplay
- Level gameplay
src/screens/game_screen.py - Maze generator
- Pac-Man entity
src/screens/classes/entities.py - Maze collectibles
src/screens/classes/entities.py - Ghost entities
src/screens/classes/entities.py - Ghost AI
src/screens/ghost_ai.py
Screens and UI
- Main menu
src/screens/main_menu.py - Pause screen
src/screens/pause_screen.py - Instructions screen
src/screens/instructions_screen.py - End screen
src/screens/end_screen.py - Highscores screen
src/screens/highscores_screen.py - Text drawer
src/screens/text.py
Configuration and scores
- Config loader
src/config.py - Highscore table
src/highscores.py
Other components
- Player
Connections 26
- Player → Game loop: starts game
README.md - Game loop → Config loader: loads settings
src/start.py - Game loop → Highscore table: loads table
src/start.py - Game loop → MLX window: creates window
src/start.py - Game loop → Main menu: dispatches input
src/start.py - Game loop → Level gameplay: creates levels
src/start.py - Game loop → Pause screen: dispatches input
src/start.py - Game loop → End screen: dispatches input
src/start.py - Game loop → Highscores screen: dispatches input
src/start.py - Game loop → Instructions screen: dispatches input
src/start.py - Level gameplay → Config loader: reads settings
src/screens/game_screen.py - Level gameplay → Maze generator: generates maze
README.md - Level gameplay → Pac-Man entity: creates entity
src/screens/game_screen.py - Level gameplay → Maze collectibles: creates items
src/screens/game_screen.py - Level gameplay → Ghost entities: creates entities
src/screens/game_screen.py - Level gameplay → Ghost AI: assigns behavior
src/screens/game_screen.py - Ghost entities → Ghost AI: requests movement
src/screens/classes/entities.py - Pac-Man entity → Maze collectibles: eats items
src/screens/classes/entities.py - End screen → Highscore table: adds score
src/start.py - Highscores screen → Highscore table: reads entries
src/screens/highscores_screen.py - Game loop → Text drawer: creates drawer
src/start.py - Main menu → MLX window: draws window
src/screens/main_menu.py - Pause screen → Text drawer: renders text
src/screens/pause_screen.py - Instructions screen → Text drawer: renders text
src/screens/instructions_screen.py - End screen → Text drawer: renders text
src/screens/end_screen.py - Highscores screen → Text drawer: renders text
src/screens/highscores_screen.py