ancatrusca
The setup
Hernán Rivas Acosta (Erlang Solutions) built Spawndemonium, a top-down multiplayer shooter shown at Code BEAM Europe. The simulation is Rust compiled to WebAssembly, running in the browser and inside a GenServer through Wasmex.
Points for Elixir developers
-
One GenServer per match, eight players max (a gameplay choice, not a performance one). The tick handler stays small: drain inputs, call Wasm, decode events, write to sockets.
-
Pick a tick interval that is a whole number of milliseconds. 30 Hz (33.3 ms) drifted; 40 Hz (25 ms) didn’t.
-
Skip JSON on hot paths. A custom binary protocol tagged with the tick lets binary pattern matching extract what the server needs, including the client timestamp used for ping.
-
Wasmex over Rustler for isolation: a broken match crashes alone.
-
Treat bots like laggy players. The demons decide five ticks ahead, which keeps them in sync across clients and gives humans time to dodge.
Try it
Clone Spawndemonium from GitHub and run make run. make release builds for a server, with an ARM target included.
Related episodes
Episode 15 with Elise Sedeno on MMO servers, episode 10 on Rust and Elixir, and the Bandit episode with Mat Trudeau.
Trending in Podcasts
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #code-sync
- #discussion
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #elixirconf-us
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #security
- #elixirconf-eu
- #processes
- #api
- #forms
- #hex










