2D Multiplayer From Scratch

submited by
Style Pass
2024-06-30 14:00:08

I recently built a game prototype for a 2D arena shooter. Here are my notes on some of the patterns I used and the design of the server and client systems.

The gameplay: players move their characters around a level, shooting bullets at other players. You gain points for hitting other players and lose points for getting hit. You can play it on desktop here, and view the source code on GitHub.

As game development projects go, the tools I used are quite high up the stack: a garbage-collected language and a web browser to run the client (but no game engine or other libraries).

The implementation time was roughly 4-5hrs over a few days. Not perfect code, but I think the separate parts fit together quite well.

Everything in my game (characters, bullets, and walls) is a game object. These game objects all implement an Entity interface which allows them to be represented in the game state and eventually rendered for the player.

Using this interface, all game objects can be treated generically during the game loop during which the objects change position, collide, or stop existing.

Leave a Comment