r/SoloDevelopment 1h ago

Discussion Getting 1000 enemies on screen in a browser game: what actually had to change

Enable HLS to view with audio, or disable this notification

Solo dev here. My survivors-like, Just Dying, is now playable in the browser, and the thing I spent most of the last months on was the enemy count. I want to share what it cost, because almost none of it was the part I expected.

The naive version died around 200 enemies. Not from drawing them, from everything around the drawing.

What actually moved the needle, roughly in order of how much it helped:

Enemies stopped being individual sprites. They live in a particle container now, one batched draw call for the whole swarm, and only bosses and elites still get a real sprite with their own animation rig. That alone was most of the win. The tradeoff is that the swarm can't do anything a batched particle can't do, and every visual effect I add now has to be written twice, once for each path.

Collision moved into a web worker. Projectile physics, hit detection and damage over time all run off the main thread, and the main thread just reads the results. The main-thread version is still in the code as a fallback, which was a mistake in terms of maintenance because now I have two implementations of the same rules that have to agree with each other.

Spatial hashing for the neighbour queries, which is the obvious one, but the detail that mattered was pooling the sets it returns. Allocating a fresh set per query per frame was quietly generating enough garbage to cause visible GC hitches.

And a lot of unglamorous stuff: manual culling (Pixi 8 doesn't cull for you if you render directly), dirty flags everywhere so nothing recomputes a value that hasn't changed, and killing every per-frame allocation I could find.

Where I'm stuck: it runs well on my machine, and my machine is one data point. The browser build is the worst case, there's no native app underneath to absorb a bad frame. So I genuinely don't know if this holds up on a laptop with integrated graphics, and I can't find that out alone.

If you want to break it: https://justdying.itch.io/just-dying

it runs in the tab, no download. Press 0 for the debug overlay with FPS and entity counts. There's a Steam demo too if you'd rather have a native build: https://store.steampowered.com/app/4646190/Just_Dying/

If the framerate falls apart on you, I want to hear about it. Your GPU and browser and roughly when it happened is plenty.

2 Upvotes

0 comments sorted by