# grumpydude02/tetris architecture

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

- Interactive diagram: https://gitdiagram.com/grumpydude02/tetris
- Repository: https://github.com/grumpydude02/tetris

## Overview

This is a Pygame Tetris clone. The player starts in the application’s menu flow, chooses Classic, Practice, or Custom play, configures options, then plays through falling-piece movement, placement, line clearing, scoring, and increasing difficulty. Custom play also supports editing and saving board presets. The graph preserves these documented capabilities; some links among unsampled menu and game code are shown as unverified rather than asserted as observed calls.

Main entry points: [`Primitives/Game.py`](https://github.com/grumpydude02/tetris/blob/master/Primitives/Game.py) (Game session), [`GameMenus.py`](https://github.com/grumpydude02/tetris/blob/master/GameMenus.py) (Mode menus), [`Main.py`](https://github.com/grumpydude02/tetris/blob/master/Main.py) (Application shell), [`Editor.py`](https://github.com/grumpydude02/tetris/blob/master/Editor.py) (Level editor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application flow"]
  node_main["Application shell<br/>[Main.py]"]
  node_states["State model<br/>[GameStates.py]"]
  node_settings["Runtime settings<br/>[Main.py]"]
  node_sound["Sound playback<br/>[Main.py]"]
end

subgraph group_modes["Modes and editing"]
  node_menus["Mode menus<br/>[GameMenus.py]"]
  node_menu_base["Menu interaction<br/>[Menu.py]"]
  node_editor["Level editor<br/>[Editor.py]"]
  node_presets["Preset files"]
end

subgraph group_gameplay["Gameplay engine"]
  node_game["Game session<br/>[Game.py]"]
  node_tetrominos["Piece movement<br/>[Tetrominos.py]"]
  node_blocks["Board blocks<br/>[Block.py]"]
end

subgraph group_ui["UI components"]
  node_buttons["Buttons<br/>[Buttons.py]"]
  node_carousel["Option carousel<br/>[Carousel.py]"]
  node_slider["Option slider<br/>[Slider.py]"]
  node_particles["Visual particles<br/>[Particles.py]"]
end

subgraph group_shared["Shared runtime"]
  node_globals["Rules and constants<br/>[Globals.py]"]
  node_functions["Game utilities<br/>[functions.py]"]
  node_timer["Game timer<br/>[Timer.py]"]
end

node_player(("Player"))

node_player -->|"starts"| node_main
node_main -->|"creates"| node_settings
node_main -->|"creates"| node_sound
node_main -->|"creates"| node_editor
node_main -.->|"routes to"| node_menus
node_main -.->|"starts session"| node_game
node_menus -->|"extends"| node_menu_base
node_menus -.->|"configures modes"| node_game
node_player -->|"chooses mode"| node_menus
node_player -->|"edits levels"| node_editor
node_editor -->|"loads and saves"| node_presets
node_menu_base -->|"handles controls"| node_buttons
node_menus -->|"creates"| node_buttons
node_menus -->|"creates"| node_slider
node_menus -->|"creates"| node_carousel
node_menu_base -->|"creates"| node_particles
node_game -->|"creates pieces"| node_tetrominos
node_game -->|"uses"| node_timer
node_game -->|"uses"| node_particles
node_game -->|"uses"| node_functions
node_game -->|"reads rules"| node_globals
node_tetrominos -->|"creates pieces"| node_blocks
node_tetrominos -->|"reads rules"| node_globals
node_tetrominos -->|"uses"| node_functions
node_blocks -->|"reads bounds"| node_globals
node_editor -->|"creates blocks"| node_blocks
node_editor -->|"uses"| node_functions
node_slider -->|"uses template"| node_buttons
node_slider -->|"maps values"| node_functions
node_carousel -->|"uses"| node_buttons
node_player -->|"plays"| node_game
node_game -.->|"plays effects"| node_sound

click node_main "https://github.com/grumpydude02/tetris/blob/master/Main.py"
click node_states "https://github.com/grumpydude02/tetris/blob/master/GameStates.py"
click node_settings "https://github.com/grumpydude02/tetris/blob/master/Main.py"
click node_sound "https://github.com/grumpydude02/tetris/blob/master/Main.py"
click node_menus "https://github.com/grumpydude02/tetris/blob/master/GameMenus.py"
click node_menu_base "https://github.com/grumpydude02/tetris/blob/master/Primitives/Menu.py"
click node_editor "https://github.com/grumpydude02/tetris/blob/master/Editor.py"
click node_presets "https://github.com/grumpydude02/tetris/tree/master/Assets/Presets"
click node_game "https://github.com/grumpydude02/tetris/blob/master/Primitives/Game.py"
click node_tetrominos "https://github.com/grumpydude02/tetris/blob/master/Tetrominos.py"
click node_blocks "https://github.com/grumpydude02/tetris/blob/master/Block.py"
click node_globals "https://github.com/grumpydude02/tetris/blob/master/Globals.py"
click node_functions "https://github.com/grumpydude02/tetris/blob/master/Tools/functions.py"
click node_buttons "https://github.com/grumpydude02/tetris/blob/master/Tools/Buttons.py"
click node_carousel "https://github.com/grumpydude02/tetris/blob/master/Tools/Carousel.py"
click node_slider "https://github.com/grumpydude02/tetris/blob/master/Tools/Slider.py"
click node_particles "https://github.com/grumpydude02/tetris/blob/master/Tools/Particles.py"
click node_timer "https://github.com/grumpydude02/tetris/blob/master/Tools/Timer.py"

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_states,node_settings,node_sound toneBlue
class node_menus,node_menu_base,node_editor,node_presets toneAmber
class node_game,node_tetrominos,node_blocks toneMint
class node_buttons,node_carousel,node_slider,node_particles toneRose
class node_globals,node_functions,node_timer,node_player toneIndigo
```

## Components

### Application flow

- [Application shell](https://github.com/grumpydude02/tetris/blob/master/Main.py): `Main.py`
- [State model](https://github.com/grumpydude02/tetris/blob/master/GameStates.py): `GameStates.py`
- [Runtime settings](https://github.com/grumpydude02/tetris/blob/master/Main.py): `Main.py`
- [Sound playback](https://github.com/grumpydude02/tetris/blob/master/Main.py): `Main.py`

### Modes and editing

- [Mode menus](https://github.com/grumpydude02/tetris/blob/master/GameMenus.py): `GameMenus.py`
- [Menu interaction](https://github.com/grumpydude02/tetris/blob/master/Primitives/Menu.py): `Primitives/Menu.py`
- [Level editor](https://github.com/grumpydude02/tetris/blob/master/Editor.py): `Editor.py`
- [Preset files](https://github.com/grumpydude02/tetris/tree/master/Assets/Presets): `Assets/Presets`

### Gameplay engine

- [Game session](https://github.com/grumpydude02/tetris/blob/master/Primitives/Game.py): `Primitives/Game.py`
- [Piece movement](https://github.com/grumpydude02/tetris/blob/master/Tetrominos.py): `Tetrominos.py`
- [Board blocks](https://github.com/grumpydude02/tetris/blob/master/Block.py): `Block.py`

### UI components

- [Buttons](https://github.com/grumpydude02/tetris/blob/master/Tools/Buttons.py): `Tools/Buttons.py`
- [Option carousel](https://github.com/grumpydude02/tetris/blob/master/Tools/Carousel.py): `Tools/Carousel.py`
- [Option slider](https://github.com/grumpydude02/tetris/blob/master/Tools/Slider.py): `Tools/Slider.py`
- [Visual particles](https://github.com/grumpydude02/tetris/blob/master/Tools/Particles.py): `Tools/Particles.py`

### Shared runtime

- [Rules and constants](https://github.com/grumpydude02/tetris/blob/master/Globals.py): `Globals.py`
- [Game utilities](https://github.com/grumpydude02/tetris/blob/master/Tools/functions.py): `Tools/functions.py`
- [Game timer](https://github.com/grumpydude02/tetris/blob/master/Tools/Timer.py): `Tools/Timer.py`

### Other components

- **Player**

## Connections

- Player → Application shell: starts (evidence: `Readme.md`)
- Application shell → Runtime settings: creates (evidence: `Main.py`)
- Application shell → Sound playback: creates (evidence: `Main.py`)
- Application shell → Level editor: creates (evidence: `Main.py`)
- Application shell → Mode menus: routes to (evidence: `Main.py`)
- Application shell → Game session: starts session (evidence: `Main.py`)
- Mode menus → Menu interaction: extends (evidence: `GameMenus.py`)
- Mode menus → Game session: configures modes (evidence: `GameMenus.py`)
- Player → Mode menus: chooses mode (evidence: `Readme.md`)
- Player → Level editor: edits levels (evidence: `Readme.md`)
- Level editor → Preset files: loads and saves (evidence: `Editor.py`)
- Menu interaction → Buttons: handles controls (evidence: `Primitives/Menu.py`)
- Mode menus → Buttons: creates (evidence: `GameMenus.py`)
- Mode menus → Option slider: creates (evidence: `GameMenus.py`)
- Mode menus → Option carousel: creates (evidence: `GameMenus.py`)
- Menu interaction → Visual particles: creates (evidence: `Primitives/Menu.py`)
- Game session → Piece movement: creates pieces (evidence: `Primitives/Game.py`)
- Game session → Game timer: uses (evidence: `Primitives/Game.py`)
- Game session → Visual particles: uses (evidence: `Primitives/Game.py`)
- Game session → Game utilities: uses (evidence: `Primitives/Game.py`)
- Game session → Rules and constants: reads rules (evidence: `Primitives/Game.py`)
- Piece movement → Board blocks: creates pieces (evidence: `Tetrominos.py`)
- Piece movement → Rules and constants: reads rules (evidence: `Tetrominos.py`)
- Piece movement → Game utilities: uses (evidence: `Tetrominos.py`)
- Board blocks → Rules and constants: reads bounds (evidence: `Block.py`)
- Level editor → Board blocks: creates blocks (evidence: `Editor.py`)
- Level editor → Game utilities: uses (evidence: `Editor.py`)
- Option slider → Buttons: uses template (evidence: `Tools/Slider.py`)
- Option slider → Game utilities: maps values (evidence: `Tools/Slider.py`)
- Option carousel → Buttons: uses (evidence: `Tools/Carousel.py`)
- Player → Game session: plays (evidence: `Readme.md`)
- Game session → Sound playback: plays effects (evidence: `Main.py`)
