Space Destroyer
Two-player spaceship duel written in Python and Pygame, networked over raw TCP sockets with a dedicated threaded server that owns matchmaking and state relay.

Overview
A spaceship duel for two players where the networking matters as much as the gameplay. Each client runs Pygame locally while a separate server process owns the connections: it assigns each player an ID, pairs them up, and keeps one thread per client for the whole match.
The problem
Pygame games are single-player by default. Sharing game state between two machines means solving synchronization yourself: who owns the truth, how state travels, and what players see while nobody else has connected.
What I built
I designed a minimal client-server protocol over TCP: a Python socket server that accepts two players, stores their latest known state, and answers every client message with its rival's state using one thread per connection. Waiting screen, pairing and the win condition all emerge from that exchange.
Key features
- Dedicated server process, independent from clients, runnable on any machine in the same network.
- Basic matchmaking: the first player waits; the second connection starts the match automatically.
- One server thread per client handling concurrent connections.
- Compact text frames carrying position, bullets, score and life per exchange.
- Classic mechanics: sideways movement, laser shots with a three-bullet limit, score per hit, hearts that resist six impacts, and a victory screen.
Technical decisions
- TCP sockets with a thread per client: ordered, reliable delivery that is simple to reason about for a two-player game.
- State relayed through the central server rather than peer-to-peer, so clients never need to know each other's address.
- Plain-text frames instead of a serialization library: trivially debuggable with prints and netcat.
Stack
- Python
- Pygame
- Sockets (TCP)
- Threading
Screenshots

