# wa1kingr3d/tetris-v1 architecture

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

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

## Overview

This is a small SFML Tetris game. The main workflow is the window loop dispatching input and updates to Game, which manages play state, falling and queued tetrominoes, collision and board-clearing rules, scoring, and game-over handling; it then draws the game. Supporting components provide board storage, piece geometry, text, music, and persistent high scores. The source excerpts show the core gameplay and some rendering and persistence behavior; details of unsampled implementation are not inferred.

Main entry points: [`tetris-v1/game.cpp`](https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/game.cpp) (Game Controller), [`tetris-v1/tetris.cpp`](https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/tetris.cpp) (Window Loop), [`tetris-v1/theMatrix.cpp`](https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/theMatrix.cpp) (Board Matrix), [`tetris-v1/musicController.cpp`](https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/musicController.cpp) (Music Controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game Runtime"]
  node_entry["Window Loop<br/>[tetris.cpp]"]
  node_game["Game Controller<br/>[game.cpp]"]
end

subgraph group_gameplay["Gameplay Model"]
  node_rules["Game Rules<br/>[game.cpp]"]
  node_pieces["Tetrominoes<br/>[tetromino.cpp]"]
  node_board[("Board Matrix<br/>[theMatrix.cpp]")]
  node_types["Shared Types<br/>[globalTypes.h]"]
  node_constants["Game Constants<br/>[constants.h]"]
end

subgraph group_presentation["Presentation"]
  node_gameview["Game Display<br/>[game.cpp]"]
  node_text["Text Rendering<br/>[text.cpp]"]
  node_music["Music Controller"]
  node_tracks["Music Tracks"]
end

subgraph group_persistence["Persistence"]
  node_scores[("High Score File<br/>[highScore.txt]")]
end

node_player(("Player"))

node_player -->|"plays"| node_entry
node_entry -->|"dispatches input"| node_game
node_entry -->|"updates"| node_game
node_entry -->|"draws"| node_game
node_game -->|"creates pieces"| node_pieces
node_game -->|"creates board"| node_board
node_game -->|"runs rules"| node_rules
node_rules -->|"reads and clears"| node_board
node_board -->|"plots piece"| node_pieces
node_game -->|"renders screen"| node_gameview
node_gameview -->|"draws labels"| node_text
node_game -->|"sets tracks"| node_music
node_music -->|"opens audio"| node_tracks
node_game -->|"reads and writes"| node_scores

click node_entry "https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/tetris.cpp"
click node_game "https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/game.cpp"
click node_rules "https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/game.cpp"
click node_pieces "https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/tetromino.cpp"
click node_board "https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/theMatrix.cpp"
click node_types "https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/globalTypes.h"
click node_constants "https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/constants.h"
click node_gameview "https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/game.cpp"
click node_text "https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/text.cpp"
click node_music "https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/musicController.cpp"
click node_tracks "https://github.com/wa1kingr3d/tetris-v1/tree/main/tetris-v1/music"
click node_scores "https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/highScore.txt"

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_entry,node_game toneBlue
class node_rules,node_pieces,node_board,node_types,node_constants toneAmber
class node_gameview,node_text,node_music,node_tracks toneMint
class node_scores toneRose
class node_player toneIndigo
```

## Components

### Game Runtime

- [Window Loop](https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/tetris.cpp): `tetris-v1/tetris.cpp`
- [Game Controller](https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/game.cpp): `tetris-v1/game.cpp`

### Gameplay Model

- [Game Rules](https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/game.cpp): `tetris-v1/game.cpp`
- [Tetrominoes](https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/tetromino.cpp): `tetris-v1/tetromino.cpp`
- [Board Matrix](https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/theMatrix.cpp): `tetris-v1/theMatrix.cpp`
- [Shared Types](https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/globalTypes.h): `tetris-v1/globalTypes.h`
- [Game Constants](https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/constants.h): `tetris-v1/constants.h`

### Presentation

- [Game Display](https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/game.cpp): `tetris-v1/game.cpp`
- [Text Rendering](https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/text.cpp): `tetris-v1/text.cpp`
- [Music Controller](https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/musicController.cpp): `tetris-v1/musicController.cpp`
- [Music Tracks](https://github.com/wa1kingr3d/tetris-v1/tree/main/tetris-v1/music): `tetris-v1/music`

### Persistence

- [High Score File](https://github.com/wa1kingr3d/tetris-v1/blob/main/tetris-v1/highScore.txt): `tetris-v1/highScore.txt`

### Other components

- **Player**

## Connections

- Player → Window Loop: plays (evidence: `tetris-v1/tetris.cpp`)
- Window Loop → Game Controller: dispatches input (evidence: `tetris-v1/tetris.cpp`)
- Window Loop → Game Controller: updates (evidence: `tetris-v1/tetris.cpp`)
- Window Loop → Game Controller: draws (evidence: `tetris-v1/tetris.cpp`)
- Game Controller → Tetrominoes: creates pieces (evidence: `tetris-v1/game.cpp`)
- Game Controller → Board Matrix: creates board (evidence: `tetris-v1/game.cpp`)
- Game Controller → Game Rules: runs rules (evidence: `tetris-v1/game.cpp`)
- Game Rules → Board Matrix: reads and clears (evidence: `tetris-v1/game.cpp`)
- Board Matrix → Tetrominoes: plots piece (evidence: `tetris-v1/theMatrix.cpp`)
- Game Controller → Game Display: renders screen (evidence: `tetris-v1/game.cpp`)
- Game Display → Text Rendering: draws labels (evidence: `tetris-v1/game.cpp`)
- Game Controller → Music Controller: sets tracks (evidence: `tetris-v1/game.cpp`)
- Music Controller → Music Tracks: opens audio (evidence: `tetris-v1/musicController.cpp`)
- Game Controller → High Score File: reads and writes (evidence: `tetris-v1/game.cpp`)
