# fxaxbxc/pac-man architecture

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

- Interactive diagram: https://gitdiagram.com/fxaxbxc/pac-man
- Repository: https://github.com/fxaxbxc/pac-man

## Overview

This repository is a terminal Pac-Man game implemented in one C++ source file. The player selects a menu option, navigates the maze while collecting dots and avoiding ghosts, then sees a win/loss result; completed scores can be saved and viewed or searched in the leaderboard. The graph separates gameplay, presentation, and score features even though they share main.cpp. The excerpt omits some function bodies and dispatch code, so only documented or excerpt-visible relationships are shown.

Main entry points: [`main.cpp`](https://github.com/fxaxbxc/pac-man/blob/main/main.cpp) (Game Loop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_game["Gameplay"]
  node_main["Game Entry<br/>[main.cpp]"]
  node_maze["Maze State<br/>[main.cpp]"]
  node_player_move["Player Movement<br/>[main.cpp]"]
  node_ghosts["Ghost Movement<br/>[main.cpp]"]
  node_collision["Collision &amp; Lives<br/>[main.cpp]"]
  node_game_loop["Game Loop<br/>[main.cpp]"]
end

subgraph group_ui["Terminal Interface"]
  node_menu["Main Menu<br/>[main.cpp]"]
  node_game_draw["Game Display<br/>[main.cpp]"]
  node_result["Game Result<br/>[main.cpp]"]
  node_instructions["Instructions View<br/>[main.cpp]"]
end

subgraph group_scores["Scores"]
  node_score_load["Load Scores<br/>[main.cpp]"]
  node_score_save["Save Score<br/>[main.cpp]"]
  node_sort["Sort Scores<br/>[main.cpp]"]
  node_leaderboard["Leaderboard View<br/>[main.cpp]"]
  node_search["Player Search<br/>[main.cpp]"]
end

node_player(("Player"))
node_ncurses["Ncurses Terminal"]
node_score_file[("Score File")]

node_player -->|"selects"| node_menu
node_menu -.->|"starts game"| node_game_loop
node_game_loop -.->|"uses state"| node_maze
node_game_loop -->|"draws"| node_game_draw
node_game_loop -.->|"updates"| node_ghosts
node_game_loop -.->|"shows result"| node_result
node_player -->|"controls"| node_player_move
node_player_move -->|"checks walls"| node_maze
node_ghosts -.->|"checks walls"| node_maze
node_ghosts -.->|"risks collision"| node_collision
node_game_loop -->|"saves finished score"| node_score_save
node_score_save -->|"writes"| node_score_file
node_score_load -->|"reads"| node_score_file
node_leaderboard -.->|"loads scores"| node_score_load
node_leaderboard -.->|"orders scores"| node_sort
node_search -->|"loads scores"| node_score_load
node_search -.->|"searches loaded data"| node_score_file
node_menu -.->|"opens"| node_leaderboard
node_menu -.->|"opens"| node_search
node_menu -.->|"opens"| node_instructions
node_game_draw -->|"renders through"| node_ncurses
node_menu -.->|"renders through"| node_ncurses
node_result -.->|"renders through"| node_ncurses

click node_main "https://github.com/fxaxbxc/pac-man/blob/main/main.cpp"
click node_menu "https://github.com/fxaxbxc/pac-man/blob/main/main.cpp"
click node_maze "https://github.com/fxaxbxc/pac-man/blob/main/main.cpp"
click node_player_move "https://github.com/fxaxbxc/pac-man/blob/main/main.cpp"
click node_ghosts "https://github.com/fxaxbxc/pac-man/blob/main/main.cpp"
click node_collision "https://github.com/fxaxbxc/pac-man/blob/main/main.cpp"
click node_game_loop "https://github.com/fxaxbxc/pac-man/blob/main/main.cpp"
click node_game_draw "https://github.com/fxaxbxc/pac-man/blob/main/main.cpp"
click node_result "https://github.com/fxaxbxc/pac-man/blob/main/main.cpp"
click node_score_load "https://github.com/fxaxbxc/pac-man/blob/main/main.cpp"
click node_score_save "https://github.com/fxaxbxc/pac-man/blob/main/main.cpp"
click node_sort "https://github.com/fxaxbxc/pac-man/blob/main/main.cpp"
click node_leaderboard "https://github.com/fxaxbxc/pac-man/blob/main/main.cpp"
click node_search "https://github.com/fxaxbxc/pac-man/blob/main/main.cpp"
click node_instructions "https://github.com/fxaxbxc/pac-man/blob/main/main.cpp"

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_main,node_maze,node_player_move,node_ghosts,node_collision,node_game_loop toneBlue
class node_menu,node_game_draw,node_result,node_instructions,node_score_file toneAmber
class node_score_load,node_score_save,node_sort,node_leaderboard,node_search toneMint
class node_player,node_ncurses toneIndigo
```

## Components

### Gameplay

- [Game Entry](https://github.com/fxaxbxc/pac-man/blob/main/main.cpp): `main.cpp`
- [Maze State](https://github.com/fxaxbxc/pac-man/blob/main/main.cpp): `main.cpp`
- [Player Movement](https://github.com/fxaxbxc/pac-man/blob/main/main.cpp): `main.cpp`
- [Ghost Movement](https://github.com/fxaxbxc/pac-man/blob/main/main.cpp): `main.cpp`
- [Collision & Lives](https://github.com/fxaxbxc/pac-man/blob/main/main.cpp): `main.cpp`
- [Game Loop](https://github.com/fxaxbxc/pac-man/blob/main/main.cpp): `main.cpp`

### Terminal Interface

- [Main Menu](https://github.com/fxaxbxc/pac-man/blob/main/main.cpp): `main.cpp`
- [Game Display](https://github.com/fxaxbxc/pac-man/blob/main/main.cpp): `main.cpp`
- [Game Result](https://github.com/fxaxbxc/pac-man/blob/main/main.cpp): `main.cpp`
- [Instructions View](https://github.com/fxaxbxc/pac-man/blob/main/main.cpp): `main.cpp`

### Scores

- [Load Scores](https://github.com/fxaxbxc/pac-man/blob/main/main.cpp): `main.cpp`
- [Save Score](https://github.com/fxaxbxc/pac-man/blob/main/main.cpp): `main.cpp`
- [Sort Scores](https://github.com/fxaxbxc/pac-man/blob/main/main.cpp): `main.cpp`
- [Leaderboard View](https://github.com/fxaxbxc/pac-man/blob/main/main.cpp): `main.cpp`
- [Player Search](https://github.com/fxaxbxc/pac-man/blob/main/main.cpp): `main.cpp`

### Other components

- **Player**
- **Ncurses Terminal**
- **Score File**

## Connections

- Player → Main Menu: selects (evidence: `README.md`)
- Main Menu → Game Loop: starts game (evidence: `README.md`)
- Game Loop → Maze State: uses state (evidence: `main.cpp`)
- Game Loop → Game Display: draws (evidence: `main.cpp`)
- Game Loop → Ghost Movement: updates (evidence: `main.cpp`)
- Game Loop → Game Result: shows result (evidence: `README.md`)
- Player → Player Movement: controls (evidence: `README.md`)
- Player Movement → Maze State: checks walls (evidence: `main.cpp`)
- Ghost Movement → Maze State: checks walls (evidence: `main.cpp`)
- Ghost Movement → Collision & Lives: risks collision (evidence: `main.cpp`)
- Game Loop → Save Score: saves finished score (evidence: `main.cpp`)
- Save Score → Score File: writes (evidence: `README.md`)
- Load Scores → Score File: reads (evidence: `README.md`)
- Leaderboard View → Load Scores: loads scores (evidence: `README.md`)
- Leaderboard View → Sort Scores: orders scores (evidence: `README.md`)
- Player Search → Load Scores: loads scores (evidence: `main.cpp`)
- Player Search → Score File: searches loaded data
- Main Menu → Leaderboard View: opens (evidence: `README.md`)
- Main Menu → Player Search: opens (evidence: `README.md`)
- Main Menu → Instructions View: opens (evidence: `README.md`)
- Game Display → Ncurses Terminal: renders through (evidence: `main.cpp`)
- Main Menu → Ncurses Terminal: renders through (evidence: `README.md`)
- Game Result → Ncurses Terminal: renders through (evidence: `README.md`)
