How jeremy-oz/godot-tetris works
Purpose and startup
This is a Godot 4.7 Tetris clone supporting solo play and multiplayer versus play. Godot launches scenes/main.tscn via project.godot; the main gameplay implementation is centered on board.gd and scenes/board.tscn.
Scene-level composition
The application is assembled as Godot scenes rather than a web/server stack:
• Main/menu routing: scenes/main.tscn
• Solo wrapper: scenes/solo.tscn, solo.gd
• Multiplayer lobby: scenes/lobby.tscn, lobby.gd
• Versus match wrapper: scenes/versus.tscn, versus.gd
• Reusable board: scenes/board.tscn, board.gd
These wrappers select game mode and compose one or more board instances.
Core board simulation
board.gd owns the Tetris state machine: falling tetromino movement, rotation/wall kicks, collision and locking, row clearing, scoring/levels, hold behavior, ghost/hard drop, and game-over conditions. Its visual and collision boundary is the board scene:
• board.gd
• scenes/board.tscn
• assets/tetrominoes.png.import
The Godot 4.7 board uses separate TileMapLayer nodes for landed/wall cells and active-piece rendering, sharing a tileset.
Solo flow
solo.gd hosts a board for local play and mediates solo-specific UI actions such as starting a new game. Input enters through Godot’s frame/input callbacks, is translated into board actions, then board state updates the TileMap layers and HUD.
• solo.gd
• scenes/solo.tscn
• scenes/board.tscn
Multiplayer lifecycle
The lobby is the network session boundary: it handles hosting/joining and the peer handshake before transitioning into versus gameplay. The versus scene then coordinates the local and remote boards, including synchronization/mirroring of player state.
• lobby.gd
• scenes/lobby.tscn
• versus.gd
• scenes/versus.tscn
Versus gameplay and outcomes
Versus mode operates two board views and propagates competitive events across the multiplayer boundary. Line clears can produce garbage for the opponent; player loss or winning status ends the match. Board mechanics remain local to board.gd, while match coordination belongs in versus.gd.
• versus.gd
• board.gd
• scenes/versus.tscn
Runtime, networking, and verification
The material runtime is the Godot 4.7 engine and GDScript; export targets are declared in export_presets.cfg. Multiplayer uses Godot’s built-in networking APIs rather than a separately represented backend service. Headless scripts provide automation entry points for board and network behavior:
• project.godot
• test_headless.gd
• test_net_host.gd
• test_net_client.gd
Main entry points: board.gd Board Simulation · board.tscn Board Scene · versus.gd Versus Controller · main.tscn Main Menu Router
Components 15
Godot Runtime
- Project Startup · Launches the main scene.
project.godot - Godot 4.7 Engine
- Headless Checks · Board and host/client automation entry points.
test_headless.gd - Export Presets
export_presets.cfg
Scene Composition
- Main Menu Router
scenes/main.tscn - Solo Scene
scenes/solo.tscn - Versus Scene
scenes/versus.tscn
Gameplay
- Solo Controller · Maps local input and new-game UI to a board.
solo.gd - Board Scene · Defines TileMapLayer rendering for active and landed cells.
scenes/board.tscn - Board Simulation · Owns local Tetris mechanics and game state.
board.gd - Tetromino Tileset
assets/tetrominoes.png.import
Multiplayer
- Lobby Scene
scenes/lobby.tscn - Lobby Controller · Hosts or joins peers and completes the session handshake.
lobby.gd - Versus Controller · Coordinates local and remote boards, garbage, and match outcomes.
versus.gd - Godot Networking APIs · Built-in peer transport and RPC boundary.
Connections 19
- Project Startup → Godot 4.7 Engine: runs on
- Project Startup → Main Menu Router: launches
- Main Menu Router → Solo Scene: routes to solo
- Main Menu Router → Lobby Scene: routes to multiplayer
- Lobby Scene → Versus Scene: enters after handshake
- Solo Scene → Solo Controller: attaches
- Solo Scene → Board Scene: hosts one board
- Solo Controller → Board Simulation: sends board actions
- Board Scene → Board Simulation: binds script
- Board Scene → Tetromino Tileset: renders with
- Versus Scene → Versus Controller: attaches
- Versus Scene → Board Scene: composes two board views
- Versus Controller → Board Simulation: coordinates board state
- Lobby Scene → Lobby Controller: attaches
- Lobby Controller → Godot Networking APIs: host/join handshake
- Versus Controller → Godot Networking APIs: syncs players and events
- Board Simulation → Versus Controller: clears and loss outcomes
- Headless Checks → Board Simulation: exercises mechanics
- Export Presets → Godot 4.7 Engine: declares export targets