Raycaster Game with Networking
I'd been skimming Bartle's Designing Virtual World and decided to write a MMO. How cliche. While working on it, I found myself reading and rereading Fabien Sanglard's Doom Black Book, a detailed look into the technology used for Doom. I've been wanting to make my own game, but a MMO is too much effort. Even Doom is too much effort. Instead I've been writing a raycaster, similar to Wolfenstein 3D, but with support for online multiplayer. The networking is great; the raycasting needs work. (Can you guess what I spend most of my work doing? Hint: It isn't computer graphics.)
A screenshot of the current state of the game is below. The image shows two clients running with a server:
The source code is here.
Raycasting
I'm still having a lot of trouble with the raycasting. Right now, I'm rendering a 2D topdown view of the game. Once I've got the collision math working, I just render the same information in a slightly different way.
Todo List:
- Fix the collision math.
- Implement a first person renderer.
- Add texture support.
Networking
Networking is going very well. With UDP, message sharing is almost trivial. There's no need to maintain a connection or determine the end of a message; everything is provided in discrete packets. The client and server share game logic code. The client polls key presses at high frequency and sends the actions to the server. The server and client calculate the new game state separately. Every so often, the server sends the latest world state to the client. This is cheap, because the only state is the state of each player.
One other feature, the server transmits the map to new players.
There are several areas for improvement:
- Add a heartbeat feature. Currently, there's no way to remove a player.
- Ensure the server isn't trivial to spoof.
- Support map rotation.
Resources used for networking:
- Valve's Developer Community
- Ruoyu Sun's Game Networking Demystified
- Ruoyu Sun's Beginner's Guide to Making a Multiplayer Game
- Gabriel Gambetta's Guide
Ruoyu Sun is part of how this ended up becoming a FPS.
Design Documents
Before I started, I sketched up a basic design document. The original game was going to be more like an adventure game, click to move. As I coded, the design changed.