Stayed up late last night (5hrs past normal bed time! 😅) hacking on some #pico8 #GameDev - trying to emulate an infinite scroll map while minimising CPU operations.

Got it working about 90%, but I think I've got some off-by-1 errors cropping up.

Current approach is to use 32 map tiles (2 screens worth), and move the camera modulo screen height within that area. At the same time; generating new map data on demand "ahead" of where the current camera window ends.

First pass was very convoluted, but second pass has considerably cut down the complexity. I wonder if there's an even easier way to do it all?

https://github.com/jesstelford/icy-8/blob/infinite-levels/main.lua#L307-L328 (see comments at the top of the file for a diagram).

#Optimization #Lua

icy-8/main.lua at infinite-levels · jesstelford/icy-8

Pico8 port of Icy Tower. Contribute to jesstelford/icy-8 development by creating an account on GitHub.

GitHub

Success! 🎉

I was right: Off-by-1 errors, and a couple unnecessary calculations which I was able to remove.

Final result is pretty succinct, and uses barely any CPU per frame for the copy operations: https://github.com/jesstelford/icy-8/blob/2d96fb334eb706b88054bbd718b802e524a3344a/main.lua#L313-L337

#pico8 #optimization #GameDev #IndieDev

icy-8/main.lua at 2d96fb334eb706b88054bbd718b802e524a3344a · jesstelford/icy-8

Pico8 port of Icy Tower. Contribute to jesstelford/icy-8 development by creating an account on GitHub.

GitHub