Little Fortune Planet Breakdown - Part 5: Performance Persmormanche!
Continued from part 4.
Part 5: Performance Persmormanche!
Uh-oh. Trouble! The browser simulation runs at slideshow speed. To be expected given the naive implementation. Besides going for a more technically sensible solution, how about we try to improve what we have.
First we start by freezing cells that don't need attention. Eventually we could keep track of a queue of cells that demand attention, but given the available time we decided to give each cell a sleep counter and skip the simulation subsystem for that cell if it is asleep. Things like dirt can typically sleep for multiple frames without affecting the simulation much.

What if we only run half the simulation each frame? We can double the simulation performance by interlacing; calculating all even rows on frame 1, all odd rows on frame 2, etc.

Luckily the simulation seems visually identical. Can you spot the difference? This pushes the game outside the slideshow experience. Still slow, but it will do!
Continued in part 6: Finishing touches, deck of cards! or play it here!