01Course project, Uppsala University, 2026
3D Asteroid Multiplayer
A two-player Asteroids duel in a 3D arena. Play a friend on the same network, or play the computer.
- My part
- The game itself: gameplay, the HUD, menus and lobby, the bot, and the game’s side of multiplayer
- Team
- Two. Marius-Raul Filipiuc built the networking layer and the relay
- Play
- 1v1 on a local network, or against a bot
- Built with
- C++ · SDL2 · OpenGL · Winsock2
- Runs on
- Windows

The game
Everything happens on one screen.
Fly your ship, shoot asteroids for points, and shoot the other ship to take its lives. The best of three 30-second rounds wins.

- Your shipThe cyan one. W thrusts, A and D turn, Space fires.
- The opponentA friend on another computer, or the bot when you play alone.
- AsteroidsBig ones break into two medium ones, medium ones into two small; small ones shatter. A hit scores 5, 10 or 20 points.
- Round timerEach round lasts 30 seconds. Win two rounds to take the match.
- Score and livesThree lives each. After a hit, a ship can’t be hurt for 1.5 seconds.
A match
From the lobby to a rematch.
Against a friend, both games meet in a lobby first. Against the bot, a match starts straight from the menu.



If a player leaves mid-match, the one who stayed wins.
Who built what
I made the game. Marius made the network under it.
A two-person course project at Uppsala University, spring 2026. Later I added the bot on my own.
Okan Ozcan
The game
Everything you see and play: the ships, asteroids, collisions and scoring; the HUD, menus and lobby; the bot; and the game’s side of multiplayer, from the host running the match to keeping both screens in sync.
C++, SDL2 and OpenGL. The Game class and its state machine; host simulation, joiner input and state sync.
Marius-Raul Filipiuc
The networking layer
The code that carries messages between the two games.
Winsock2 sockets. A receive thread keeps only the newest state or input message, so a game never works through a backlog; Nagle’s algorithm is off on both ends.
Marius-Raul Filipiuc
The relay
A small server that pairs the two players and passes their messages along.
server.py, in Python: pairs a host and a joiner over TCP, then forwards every line between them.
Multiplayer
One player hosts, so both see the same match.
Only the host’s game runs the match. The other game sends its key presses and shows what the host sends back. Both connect through a small relay, which pairs them up.
Joining player
sends key presses
Relay
passes messages on
Host
runs the match
On a local network that round trip takes only a few milliseconds (6 ms in the LAN match above), so the delay is hard to notice.
Technical detail
- Authoritative host
- The host applies the joiner’s latest input and runs the same
UpdatePlayingas an offline match. The joiner simulates nothing. - Rates
- The joiner sends its input about 30 times a second; the host sends a full snapshot of the game state about 30 times a second.
- Between snapshots
- The joiner moves ships, asteroids and shots along their last velocities, then takes each snapshot as the truth.
- No client-side prediction
- The joiner’s own ship responds after a round trip to the host: fine on a LAN, not over the internet.
- Full snapshots
- The host resends the whole state rather than changes, so a joiner that misses a message is correct again at the next one.
The bot
The bot plays with the same controls as you.
Every ship is steered by the same four inputs, whether they come from a keyboard, the network or the bot. So the bot only had to press buttons: its ship moves, fires and gets hit through the same code as yours.
Four inputsInputState
thrust · turn left · turn right · fire
The same ship rulesUpdatePlayer
movement, cooldown and firing, for both ships in every mode
The matchUpdatePlaying
collisions, damage and score
How it plays
- It thinks in moments
- It picks a new plan every 0.15 to 0.30 seconds, not every frame.
- It dodges first
- It works out which asteroid would hit it soonest and gets out of the way.
- Then it hunts
- It chases and shoots you, or shoots asteroids for points while you can’t be hurt.
- It misses on purpose
- Only a partial lead on moving targets, a few degrees of random error, and a short pause between shots.
A handful of simple rules with timers and randomness. It doesn’t plan ahead.
Details
Small rules that keep it fair.
Fast shots can’t skip through
A shot is checked along the whole path it travelled since the last frame, in up to 20 small steps, so it can’t pass through a small asteroid or a ship between two frames.
The field refills itself
Asteroids break apart as they’re hit, and new ones drift in from the edges when the field thins out.
One set of rules
The host runs the match, the other game never does, and the bot only supplies input, so the rules can’t drift apart between modes.
Technical detail: one frame
Main loop
Main.cpp, once per frame, with the frame time dt
Game::Update(dt)
menunicknamelobbyplayinground endmatch end
UpdatePlaying(dt)
ships move from their InputState; shots and asteroids move; collisions, scoring, the round timer
Game::Draw()
the OpenGL arena, the SDL2_ttf HUD and menus
One Game class. The bot goes straight from the menu into a match; a LAN game goes through the lobby first.
Limits
What it doesn’t do.
- LAN only. Both games connect to the relay by typing its IP address; there is no matchmaking or online play.
- No client-side prediction. On a LAN you won’t notice; over the internet the joining player’s ship would feel a step behind.
- Windows only, because of Winsock2 and the Visual Studio project.
- A simple bot. A few rules with timers and randomness, not a planner.