I rebuilt my 2018 agar.io clone around real orbital physics, with no game server
In 2018 I spent a weekend making an agar.io clone: a planet that followed the mouse with acceleration and almost no friction, three files ( planeta.js , vector.js , functions.js ) and a comment that said F = G * m1 * m2 / r² . Eight years later that comment is the whole game. Lagario 3: Órbita is a free multiplayer browser game where your planet has momentum, stars pull with inverse-square…
In 2018, writer made an Agar.io clone in a single weekend. The game features a planet that follows the mouse with acceleration and little friction, using three files - planeta.js, vector.js, and functions.js. After eight years, writer discovered that this one comment forms the entire game. Lagario 3: Órbita is a free multiplayer browser game where players control planets with momentum, and stars exert gravity on them.
The game is hosted on Vercel, and serverless functions are not used for multiplayer. Instead, WebRTC is used for real-time communication, and public Nostr relays are used for signaling. The simulation runs in a Web Worker at 30 ticks per second, allowing the host to alt-tab without freezing the room.
Three key takeaways from building Órbita include:
1. Multiplayer without a server: The host creates a room and runs the simulation in a Web Worker at 30 ticks per second. Other players connect over WebRTC, and the simulation continues even when the host alt-tabs. The worker remains more stable than server-side timers.
2. Gravity: The game features realistic gravity governed by the inverse-square law, with additional tweaks for gameplay. Gravity is scaled by the player's ability to push back, and the pull on a planet is multiplied by its thrust relative to a starting planet's. Slingshots increase a planet's speed, capped at three times the top speed.
3. Collisions: Planets smaller than 25% apart in mass collide, with an impulse and restitution of 0.45. Colliding planets lose up to 25% of their mass as chunks, which can be collected by other planets. Player versions are still playable, and the game has three archives: /, /v1/, and /v2/.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.