3 ms·
I built a game using Rapier! Using its deterministic mode, I built an online multiplayer game whereby players take turn slamming bugs against the other team and
by evrimoztamur 3y ago
I built a game using Rapier! Using its deterministic mode, I built an online multiplayer game whereby players take turn slamming bugs against the other team and capture the hill.
It doesn't have a single-player mode yet (writing an AI for it is a bit more challenging than the chess-like I made) but check it out at https://evrimzone.itch.io/crittershowdown https://evrimzone.itch.io/crittershowdown and the physics/game logic source code at https://github.com/evrimoztamur/crittershowdown/blob/e4d9a1928146197f271b526a38bf8224a9dbf1c3/shared/src/logic/game.rs#L146 https://github.com/evrimoztamur/crittershowdown/blob/e4d9a19....
I plan to write a post about how I wired it together and what I learned, but overall very solid library and well-thought of Rust-y API that enabled me to do everything I needed it to.
- abricq 3y agoLooks real fun. Was it easy to deploy it on your website ? did you compile in web-assembly ? Or are you hosting all the logic onto a local server ?
- evrimoztamur 3y agoFor the deployment, I am running the server applications for both Maginet (https://evrimzone.itch.io/maginet https://evrimzone.itch.io/maginet) and Critter Showdown on the same $5 server, under a different subdomain. These subdomains are reverse-proxied by nginx behind Let's Encrypt certificates. Game servers host lobby and game logic, and are compiled to native Rust binaries. The client-side is compiled to WebAssembly (I don't use an engine, so it's all wasm-bindgen) and the Steam version (of Maginet) is just a thin Electron wrapper around the same thing that runs in the browser. In both games, the client and server share all the game related logic, with the server orchestrating synchronization of states, and client wrapping it all with the I/O. Was it easy? In the end, sure, it's a very simple system. However, a lot of gotchas including HTTP headers (connecting itch.io to my personal domain, or making sure that when the game updates the clients pick up the new binary). I wrote about the client/server part of Maginet and its technical aspects over at https://evrim.zone/blog/projects/maginet/development_overview https://evrim.zone/blog/projects/maginet/development_overvie.... However, I did not write much about the deployment. Both Critter Showdown and Maginet are essentially the same framework, I built the former in two weeks for a jam based on the stripped-down Maginet shell. If you follow the instructions on GitHub, you should be able to download and run both of them quite easily. Build client, build and run server, then head out to localhost:port to play! PS: Maginet runs the shared game logic on the server side, but Critter Showdown (with Rapier2D physics) does not. Maginet has a stricter move validation logic (legal vs illegal turns for your mages) that Critter Showdown doesn't (force impulse vectors for your bugs). Turns are passed in Critter Showdown only when both players' turns are received, and it works pretty seamlessly.
- excsn 3y agoI've actually started using Rapier2D to write a multiplayer game on the server side, so I hope to see your post soon.
- dnadler 3y agoThanks for posting this project! I’ve been curious about wasm with rust and I found your code to be really easy to follow, and gave me a really good idea of how I could get started with a similar project. Kudos!