How I built a 3D multiplayer browser game alone: a developer's diary
Chalo Jantar Mantar is built and run by one person. People often ask how a game with a 3D city, crowds of hundreds and online matches can be made alone. Here are the main decisions behind it, and what I learned.
Start with the browser
I wanted anyone to be able to play from a link, on a cheap phone or an office computer, without installing anything. That meant building for the web. The game is written in TypeScript, and the city is drawn with three.js, a library for 3D graphics in the browser (WebGL). An Android app came later, as a thin wrapper around the same web game.
One set of rules, run twice
The most important decision was to write the game's rules once, as a plain simulation with no graphics and no networking in it: who moves where, who joins whose kafila, when a barricade falls, when a round ends. The online server runs that simulation as the referee, thirty times a second. The offline practice mode runs the very same code in your browser. A rule fixed once is fixed everywhere, and the game can be tested without ever opening a browser.
Multiplayer that feels instant
Online, the server is the referee, but waiting for its answer before moving your own character would feel sluggish. So the game predicts your own movement on your device and quietly corrects it when the server's word arrives. Other players' positions are smoothed between updates. The multiplayer framework is Colyseus, and the server sends only what has changed, and only as often as it matters, so matches stay smooth on mobile data too.
Bots that play fair
A new game has few players, and an empty match is no fun. Bots fill every empty place. They don't cheat: they make the same inputs a human would (move here, shout a naara, push this barricade) and follow the same rules. They also help in testing, because a full bot match can run in seconds on a computer, without anyone playing.
Crowds of hundreds on a phone
Drawing hundreds of moving people is the hardest part for a phone. Each part of a person (bodies, heads, flags, placards) is drawn as one batch for everyone at once, instead of one by one. People far from the camera use simpler models. Phones run at thirty frames a second to stay cool, and the graphics setting can make things lighter still. The 3D models come from free, public-domain collections by Quaternius and Kenney, and many of the sounds are real recordings from Wikimedia Commons.
A city that feels like Delhi
The map is a squeezed version of central New Delhi: Connaught Place's circles, Janpath, Sansad Marg, India Gate and Jantar Mantar's own instruments. Shops get Indian names and signboards, autos and taxis drive the roads, a chai stall waits on the corner, and the news ticker runs made-up satirical headlines. Festivals change the city by date: lights at Diwali, colours at Holi, the tricolour in August and January.
Keeping it fair and friendly
Any online game attracts people who try to break it, so every message from a player's device is checked on the server, and names are filtered for abuse and for real politicians' names. Because the game is satire about a sensitive subject, everything in it is fictional, and it never takes a side. A disclaimer is shown before the first match.
Shipping small, and often
Players notice when a game is alive. New things arrive often, but in a calm way: several features are built together, released at once, and then switched on one per day, so returning players find something new without the game changing under their feet every hour.
What I learned
- Write the rules first. A clean simulation made multiplayer, bots, offline play and testing far easier.
- Test on the slowest phone you can find. If it runs there, it runs everywhere.
- Listen to players. Many of the best changes, like the floating joystick and the sea around the city, came from watching people play.
- Small and steady beats big and rare. A little improvement every few days kept the game moving.
If you have questions about how something in the game works, or ideas for what to build next, I'd love to hear them on the contact page.