Show HN: Multiplayer lunar lander game built on partykit / rapier, open source
Play it here: https://lander.gg
Code here: https://github.com/chungwu/combat-lander
Architecturally, for each match, there's a server and many clients. The server and each client all run the same physics simulation of the game world, but the server holds the authoritative state and broadcasts player inputs to all clients.
The server is spun up via partykit as a cloudflare durable object. Partykit is great; you code the server as if it's there's just one server, and partykit takes care of instantaneously spinning one up whenever you need one. It communicates with clients via web sockets and is fast.
I'm using the rapier physics engine, which is written in rust with Javascript bindings. It supports deterministic simulation, which is important to make sure all parties can run simulations independently but end up with the same world state at each time step. It also supports taking snapshots of the game world, which makes it possible for each party to keep historical snapshots of the game world at each time step so they can rebase user inputs from other players as they are received, to keep the simulation in step. Occasionally, the server also broadcasts its entire authoritative game state to make sure everyone agrees.
The game starts you out in a public room, but you can create a private game as well (just go to https://lander.gg/whatever). Turn off infinite health and fuel for the full experience!
I'm not a game developer so this is just a random passion project! It started 20 years ago (!) when I was a TA for a CS class at Berkeley, and I helped design and teach an experimental programming class aimed at (non-cs) engineers. The final project asked students to implement some physics simulation of a simple lunar lander game. The original project page is somehow still online here: https://inst.eecs.berkeley.edu/~cs4/fa04/prj/
The project was a lot of fun to put together, and even though it was challenging, the students had a lot of fun with it too. After the class was over, I continued hacking on the game, adding weapons and allowing two players to play side-by-side on the same keyboard. I always wanted to make it network-multiplayer, but started my first job and never got to it.
Fast forward 20 years! With recent advancements like partykit, I wanted to give it a try, and rebuilt the game with network multiplayer as the main focus, and with a real physics engine! It was fun to hack on
chrisjj|2 years ago