Skip to content

Baked lights

Latest
Compare
Choose a tag to compare
@NPException NPException released this 30 Sep 16:25
· 2 commits to main since this release

This is the result of my experiments to get the game running smoothly on the real Playdate hardware.

The original version unfortunately only ran at 10fps on the device, so I started looking for the bottleneck.
Which turned out to be the SDK function drawBlurredImage, which is really slow for large images.

First I attempted to generate every frame for each light cone when the game starts. That worked fine in the Simulator, but ground the real Playdate to a halt. Next, I tried to generate every frame in the Simulator and store them each in their own .pdi file. Those I copied back into the source folder, so that the real device could just load them from storage. It worked, but with hundreds of images per light cone, the loading times were still too bad on the device. Finally I tried to render all frames of a light cone animation into a single long image strip on the Simulator and save that to storage. Then I again copied the resulting images to the source folder, so they could be just read from disk on the device.

It worked really well, and that's the version attached here.
The only obvious downside is that the game is now much larger than before. (~8Mb vs ~3Mb)

The relevant code for it can be seen here: Source/hanglights.lua#L21-L64
The resulting files are then copied into the source by running this: copy-baked-lights.bat

Leave some love for the original game here: https://possiblyaxolotl.itch.io/lights-out