# yazeedbarakat/pacman architecture

> Architecture diagram of the GitHub repository yazeedbarakat/pacman, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yazeedbarakat/pacman
- Repository: https://github.com/yazeedbarakat/pacman

## Overview

Pac-Man is a Pygame arcade game: the player enters through the game’s menu and controls Pac-Man through generated maze levels, collecting pellets and avoiding ghosts; the run ends in a saved high-score entry or progression to the next level. The architecture separates orchestration, maze and entity behavior, screens/rendering, and score persistence. README capabilities include configuration, ghost AI, cheat controls, and high-score rankings. Some game.py wiring is inferred only where its excerpt documents the behavior; uncertain implementation links are omitted.

Main entry points: [`game.py`](https://github.com/yazeedbarakat/pacman/blob/main/game.py) (Game Loop), [`maze_pacgum.py`](https://github.com/yazeedbarakat/pacman/blob/main/maze_pacgum.py) (Maze And Pellets), [`pacman_setup.py`](https://github.com/yazeedbarakat/pacman/blob/main/pacman_setup.py) (Pac-Man Entity), [`ghost_renderer.py`](https://github.com/yazeedbarakat/pacman/blob/main/ghost_renderer.py) (Ghost Renderer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_play["Game Flow"]
  node_game["Game Loop<br/>[game.py]"]
end

subgraph group_world["Maze And Entities"]
  node_maze["Maze And Pellets<br/>[maze_pacgum.py]"]
  node_pacman["Pac-Man Entity<br/>[pacman_setup.py]"]
  node_ghost["Ghost AI<br/>[ghost.py]"]
end

subgraph group_view["Screens And Rendering"]
  node_ghostview["Ghost Renderer<br/>[ghost_renderer.py]"]
  node_screens["Screens And HUD<br/>[displays.py]"]
  node_assets["Game Sprites"]
end

subgraph group_records["Configuration And Scores"]
  node_config["Config Parser<br/>[config_parser.py]"]
  node_configfile["Game Config<br/>[config.json]"]
  node_scores["High Scores"]
  node_scorefile[("Score JSON<br/>[pc.json]")]
end

node_player(("Player"))
node_pygame["Pygame"]
node_generator["MazeGenerator"]

node_player -->|"provides input"| node_game
node_game -->|"dispatches events"| node_pygame
node_game -->|"loads settings"| node_config
node_configfile -->|"read by"| node_config
node_game -->|"builds levels"| node_maze
node_maze -.->|"generates maze"| node_generator
node_game -->|"creates and updates"| node_pacman
node_game -->|"updates and checks"| node_ghost
node_pacman -->|"moves on grid"| node_maze
node_ghost -->|"validates moves"| node_maze
node_game -->|"draws screens"| node_screens
node_game -->|"draws ghosts"| node_ghostview
node_ghostview -->|"renders state"| node_ghost
node_game -->|"records run"| node_scores
node_screens -->|"loads rankings"| node_scores
node_scores -->|"reads and writes"| node_scorefile
node_screens -->|"draws UI"| node_pygame
node_maze -->|"draws maze"| node_pygame
node_pacman -->|"draws player"| node_pygame
node_ghostview -->|"draws sprites"| node_pygame
node_ghostview -->|"loads sprites"| node_assets
node_pacman -->|"loads frames"| node_assets

click node_game "https://github.com/yazeedbarakat/pacman/blob/main/game.py"
click node_config "https://github.com/yazeedbarakat/pacman/blob/main/config_parser.py"
click node_configfile "https://github.com/yazeedbarakat/pacman/blob/main/config.json"
click node_maze "https://github.com/yazeedbarakat/pacman/blob/main/maze_pacgum.py"
click node_pacman "https://github.com/yazeedbarakat/pacman/blob/main/pacman_setup.py"
click node_ghost "https://github.com/yazeedbarakat/pacman/blob/main/ghost.py"
click node_ghostview "https://github.com/yazeedbarakat/pacman/blob/main/ghost_renderer.py"
click node_screens "https://github.com/yazeedbarakat/pacman/blob/main/displays.py"
click node_scores "https://github.com/yazeedbarakat/pacman/blob/main/high_scores_config.py"
click node_scorefile "https://github.com/yazeedbarakat/pacman/blob/main/pc.json"
click node_assets "https://github.com/yazeedbarakat/pacman/tree/main/assets"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_game toneBlue
class node_maze,node_pacman,node_ghost toneAmber
class node_ghostview,node_screens,node_assets toneMint
class node_config,node_configfile,node_scores,node_scorefile toneRose
class node_player,node_pygame,node_generator toneIndigo
```

## Components

### Game Flow

- [Game Loop](https://github.com/yazeedbarakat/pacman/blob/main/game.py): `game.py`

### Maze And Entities

- [Maze And Pellets](https://github.com/yazeedbarakat/pacman/blob/main/maze_pacgum.py): `maze_pacgum.py`
- [Pac-Man Entity](https://github.com/yazeedbarakat/pacman/blob/main/pacman_setup.py): `pacman_setup.py`
- [Ghost AI](https://github.com/yazeedbarakat/pacman/blob/main/ghost.py): `ghost.py`

### Screens And Rendering

- [Ghost Renderer](https://github.com/yazeedbarakat/pacman/blob/main/ghost_renderer.py): `ghost_renderer.py`
- [Screens And HUD](https://github.com/yazeedbarakat/pacman/blob/main/displays.py): `displays.py`
- [Game Sprites](https://github.com/yazeedbarakat/pacman/tree/main/assets): `assets`

### Configuration And Scores

- [Config Parser](https://github.com/yazeedbarakat/pacman/blob/main/config_parser.py): `config_parser.py`
- [Game Config](https://github.com/yazeedbarakat/pacman/blob/main/config.json): `config.json`
- [High Scores](https://github.com/yazeedbarakat/pacman/blob/main/high_scores_config.py): `high_scores_config.py`
- [Score JSON](https://github.com/yazeedbarakat/pacman/blob/main/pc.json): `pc.json`

### Other components

- **Player**
- **Pygame**
- **MazeGenerator**

## Connections

- Player → Game Loop: provides input
- Game Loop → Pygame: dispatches events
- Game Loop → Config Parser: loads settings
- Game Config → Config Parser: read by
- Game Loop → Maze And Pellets: builds levels
- Maze And Pellets → MazeGenerator: generates maze
- Game Loop → Pac-Man Entity: creates and updates
- Game Loop → Ghost AI: updates and checks
- Pac-Man Entity → Maze And Pellets: moves on grid
- Ghost AI → Maze And Pellets: validates moves
- Game Loop → Screens And HUD: draws screens
- Game Loop → Ghost Renderer: draws ghosts
- Ghost Renderer → Ghost AI: renders state
- Game Loop → High Scores: records run
- Screens And HUD → High Scores: loads rankings
- High Scores → Score JSON: reads and writes
- Screens And HUD → Pygame: draws UI
- Maze And Pellets → Pygame: draws maze
- Pac-Man Entity → Pygame: draws player
- Ghost Renderer → Pygame: draws sprites
- Ghost Renderer → Game Sprites: loads sprites
- Pac-Man Entity → Game Sprites: loads frames
