Super Nova Arena is a small PvP game that runs in a browser tab. Your mouse is your player, a glowing star. Pull back, let go, and you sling a shot at someone else. Space puts up a shield, right click (or Q) drops a mine, and after 90 seconds whoever has the most KOs wins. Up to 8 people can share a lobby.
The part I actually want to talk about is the plumbing, because there isn't any. No game server, no backend at all. The site is a static page on GitHub Pages and players connect straight to each other.
How the connecting works
We use Trystero with its Nostr strategy. Public Nostr relays only help peers find each other, and once they have, everything goes over WebRTC directly between players.
For the lobby list, everyone joins one shared room called lobby-index, and each person advertises which lobby they're in through their user state. Every lobby is its own room, capped at 8. Inside a lobby there are three things going on: each player's state (name, color, health, KOs, downs, wins, whether they're dead), an event channel for shots, mines, shields and hits, and one shared match object for the round.
A round goes waiting, countdown, live, over, then around again. The bit I like is that every transition is tied to the round number, so any player can push it forward and it doesn't matter if two of them do it at the same moment. There's no host to lose. Everything coming in from other players gets validated and rate-limited, since we can't trust anybody.
The rest of it
It's one index.html. CSS and JS are inline, no framework, no build step. The only outside code is two vendored modules that load when needed: Trystero when someone opens the lobby panel, and modern-screenshot when someone sends a bug report with a screenshot.
Physics runs on a fixed 1/120 second step on a virtual 1600x900 table that gets stretched to fit your screen. Other players' positions are smoothed between updates so they don't jitter around. For the slingshot you stand still, press to plant, pull back (up to 330 units) and let go. A full pull does 2 damage.
Rendering has a couple of tricks. The nebula clouds are drawn on an offscreen layer at 0.45 resolution. The page also checks your monitor's refresh rate and only draws every Nth frame to land near 60 FPS, so 60 and 120 Hz screens run at 60 and a 144 Hz screen settles at a steady 72. If it's still slow, it drops to 1x pixel density.
Where it falls apart
- Each player decides for themselves whether they got hit. That kept things simple, but it means cheating is easy.
- There's no TURN server, so some strict networks just can't connect.
- Everyone in a lobby can see everyone else's IP address. The lobby panel says so, but still.
Come break it
If you've built peer-to-peer netcode before, I'd love to hear what's going to bite us later. Or just play it at flirtworks.co. Practice vs bots works if nobody's around, which, this early, is most of the time. It's early access, so there's a Bug button at the top right that sends reports straight to our Discord.