ESSAY20267 min

Reaxxion Devlog #2: The Slime Stays

Reaxxion really suffered on my iPhone 13, and the slime creatures were the reason. I was never going to make them simpler, so everything around them had to get cheaper.

ENTRY

On my desktop, Reaxxion wasn't the smoothest thing I've ever played. On my iPhone 13, it really suffered.

If you read the last devlog, you already know about one of my screwups: every blob on the board was being drawn thousands of times. That turned out to be one problem out of several.

The thing I wouldn't trade

When a game runs badly on a phone, the obvious move is to make the expensive thing simpler. In Reaxxion, the expensive thing is the slime.

I never considered it.

The feel of those creatures is too important to this game. I wanted organic slime blobs, the raindrops-on-a-car-window thing I wrote about last time, and a board of tidy little tokens would be a different game.

So the slime stays, and everything around the slime had to get cheaper.

Why slime is heavy

Here's what surprised me: metaballs are heavy.

A normal game piece is a model. Somebody builds its shape once, and the computer draws it wherever it needs to be. A metaball doesn't have a shape. It has a zone of influence, like the pull around a magnet, and the surface you see is wherever that pull is strong enough. When two blobs get close, their pull adds up and the surface bridges the gap between them. That's why they merge like raindrops.

The catch is that the surface has to be worked out fresh every time anything moves. During a capture, when one blob is reaching for another, that's every single frame.

On screen it's one smooth, simple-looking mass. Underneath, it's the most expensive thing in the game.

What I changed

Most of what I fixed was waste.

Every time a blob was rebuilt, the game sent its whole block of reserved memory to the graphics chip, including the big empty part the new shape wasn't using. Sending only what had actually changed doubled the frame rate in testing, from 71 frames per second to 143. Later I found the game was also re-sending every creature on the board around a capture, whether it had moved or not. Stopping that cut those uploads from 10 to 12 megabytes down to less than half of one.

The rebuilding itself was happening in line with everything else the game has to do, so while a blob was being worked out, nothing else could happen. That work now runs in the background, and the typical frame went from 13.7 milliseconds to 7.

Each capture was also building brand-new blobs and throwing the old ones away, which stalled the game for a tenth to a third of a second on every move. (A third of a second doesn't sound like much until it happens every time you take a turn.) Now the game keeps a pool of blobs and reuses what it has, and when a creature changes sides, it changes color in place. The worst stall dropped from 327 milliseconds to 153.

The last change is the only one that touches the slime, and only on phones. The blobs there are built a little coarser, and they stop drifting and bubbling when nothing is happening. They still breathe. That took the typical frame on a crowded board from 20.9 milliseconds to 13.9.

Those numbers come from a simulated phone: my desktop browser, set to the phone's quality level, with the processor slowed to a quarter of its speed, on a crowded board with the game playing itself. They aren't from my iPhone. Each one was measured separately, under slightly different conditions, so you can't multiply them together and call it a total.

Same arrangement as last time, by the way. My AI assistant did the measuring and wrote the code. I decided what wasn't up for negotiation.

Where it stands

On the actual iPhone 13, it feels much better.

There's still quite a bit of tweaking to do. It's not always easy to select the piece you want, or to put it exactly where you want it to go. And because the game lives on a website, on a phone, I'm dealing with strange aspect ratios that don't quite fit the board I designed.

So that's where the work goes next: making pieces easier to pick on a touch screen, and getting the board to sit properly on screens it wasn't drawn for.

Loading...