How usernob/sfml-tetris works
SFML-Tetris is a C++ desktop Tetris clone. The main workflow is window events into Game input, timed game-state updates, and drawing the board, score, and next-piece preview; piece generation, collision/line handling, and audio support that loop. The README identifies the clone and SFML, while the excerpts show these runtime responsibilities. Grid internals are only partially sampled, so the diagram omits uncertain calls and does not infer additional UI or gameplay systems.
Main entry points: game.cpp Game controller · grid.cpp Board movement and lines · pieces.cpp Piece shapes and rotation · main.cpp Application loop
Components 15
Game runtime
- Application loop
src/main.cpp - Game controller
src/game.cpp - Audio and font assets
assets
Gameplay
- Timed play and score
src/game.cpp - Keyboard controls
src/game.cpp - Board movement and lines
src/grid.cpp
Board rendering
- Board grid state
src/grid.cpp - Grid drawing
src/grid.cpp - Next-piece preview
src/grid.cpp
Piece support
- Piece shapes and rotation
src/pieces.cpp - Random selection
src/utils.cpp - Game constants and types
src/constant.h - Bundled media files
assets
Other components
- Player
- SFML window
Connections 22
- Player → SFML window: uses
- SFML window → Application loop: delivers events
src/main.cpp - Application loop → Game controller: initializes and calls
src/main.cpp - Application loop → SFML window: clears and displays
src/main.cpp - Game controller → Keyboard controls: handles keys
src/game.cpp - Game controller → Timed play and score: updates and draws
src/game.cpp - Game controller → Audio and font assets: loads media
src/game.cpp - Keyboard controls → Board movement and lines: moves and rotates
src/game.cpp - Timed play and score → Board movement and lines: checks rows and locks
src/game.cpp - Timed play and score → Piece shapes and rotation: selects next piece
src/game.cpp - Timed play and score → Next-piece preview: updates preview
src/game.cpp - Timed play and score → Audio and font assets: plays effects
src/game.cpp - Board movement and lines → Board grid state: changes cell state
src/grid.cpp - Grid drawing → Board grid state: draws vertices
src/grid.cpp - Next-piece preview → Board grid state: updates cells
src/grid.cpp - Piece shapes and rotation → Random selection: chooses shape and color
src/pieces.cpp - Board movement and lines → Piece shapes and rotation: rotates piece
src/grid.cpp - Piece shapes and rotation → Game constants and types: uses piece types
src/pieces.cpp - Board movement and lines → Game constants and types: uses board dimensions
src/grid.cpp - Game controller → Grid drawing: draws board
src/game.cpp - Game controller → Next-piece preview: draws preview
src/game.cpp - Bundled media files → Audio and font assets: provides files