
TetriC
A modular, console-based multiplayer Tetris game built in C for a university Software Engineering project. Features single-player, local two-player, and socket-based network multiplayer over TCP.
The Problem
Implementing real-time interactive multiplayer in a resource-constrained terminal environment requires strict frame timing, low-latency socket networking, and cross-platform terminal I/O handling in pure C.
Technical Approach
Built a modular ANSI terminal game engine in C11 with matrix-based collision detection, non-blocking keyboard input, and Windows Winsock2 TCP socket networking for multiplayer matches.
TetriC Multiplayer Terminal Session (2-Player TCP Socket)
┌── PLAYER 1 (Local) ──┐ ┌── PLAYER 2 (Remote) ─┐ │ SCORE: 01420 LVL: 04 │ │ SCORE: 01180 LVL: 04 │ │ [■][■] │ │ [■][■] │ │ [■][■] NEXT: Z │ TCP │ [■][■] │ │ ───PACKET──> │ │ [■][■][■][■] │ PORT │ [■][■][■] │ │ [■][■][■][■][■][■][■] │ 8080 │ [■][■][■][■][■][■][■] │ └───────────────────────┘ └───────────────────────┘ [CLIENT] Sent BOARD_UPDATE payload (200 bytes) | Frame latency: sync ok
Terminal representation of the non-blocking matrix rendering and network packet synchronization.
Key Highlights & Architecture
- Console-based Tetris implemented in pure C with matrix rotation and collision algorithms
- Local two-player and socket-based network multiplayer over TCP
- Dynamic score progression, levels, and persistent high score leaderboards
Engineering Challenges
- Synchronizing piece drop ticks and line clears between two separate network machines without gameplay jitter.
- Handling ANSI terminal escape codes and screen buffering cleanly in the Windows console environment without tearing.
Key Engineering Decisions
- Non-blocking I/O with select(): Enabled concurrent handling of player keypresses and incoming network socket packets.
- Compact Binary Network Protocol: Encoded board states and line-clear events into lightweight fixed-size binary structs.
Trade-Off Analysis & Architectural Rationale
Non-blocking select() Event Loop
Multi-threaded blocking socket reads
Ensures game tick updates and keyboard inputs are never stalled by delayed network packets.
Requires state machine handling of partial packet reads across socket buffers.
Result & Outcome
Successfully created and demonstrated a responsive, network-capable terminal Tetris game for a university Software Engineering project.