How mharcerz/tetris works
Tetris is an SFML desktop game. The principal workflow starts in main, which creates the window and game objects, then delegates to screen routines for start, username entry, gameplay, and game-over/replay. Gameplay state tracks the active and next pieces, board placement, scoring, and row clearing; visualization renders the game and input supplies controls. The README is only a title, so detailed capabilities and several internal calls are inferred from interfaces and the source index; unverified links are dashed.
Main entry points: GameState.cpp Game state · main.cpp Game entry · Run.cpp Screen flow · BlockOnBoard.cpp Active piece movement
Components 15
Application flow
- Game entry
src/main.cpp - Screen flow
src/gameLogic/Run.cpp
SFML interface
- User input
src/sfml/UserInput.cpp - Game rendering
src/sfml/Visualization.cpp
Game rules
- Game state
src/gameLogic/GameState.cpp - Board scoring
src/gameLogic/GameBoard.cpp - Active piece movement
src/gameLogic/BlockOnBoard.cpp - Game dimensions
src/GameConstants.h - Board occupancy matrix
src/gameLogic/BoolMatrix.tpp
Piece construction
- Piece patterns
src/gameLogic/BlockPattern.cpp - Colored pieces
src/gameLogic/BlockWithColor.cpp - Pattern factory
src/gameLogic/Factory/BlockFactory.cpp - Color factory
src/gameLogic/Factory/ColorFactory.cpp - Piece factory
src/gameLogic/Factory/ColoredBlockFactory.cpp
Other components
- Player
Connections 20
- Game entry → Screen flow: calls screens
src/main.cpp - Game entry → User input: creates input
src/main.cpp - Game entry → Game rendering: creates renderer
src/main.cpp - Game entry → Game state: creates state
src/main.cpp - Player → User input: provides controls
- Screen flow → User input: uses controls
- Screen flow → Game rendering: requests rendering
- Screen flow → Game state: advances game
- Game state → Board scoring: updates board
- Game state → Active piece movement: moves pieces
- Game state → Piece factory: creates pieces
- Game rendering → Game state: reads game state
- Piece factory → Pattern factory: requests pattern
- Piece factory → Color factory: requests color
- Pattern factory → Piece patterns: produces pattern
- Colored pieces → Piece patterns: extends pattern
- Active piece movement → Colored pieces: extends piece
- Board scoring → Board occupancy matrix: tracks occupancy
- Board scoring → Active piece movement: places piece
- Active piece movement → Game dimensions: uses dimensions