Here is just a weird lighting platformer thing I made a while ago, not much of a game.
I played around a bit with the code, particularly PC, _draw, and _update functions and took it from about 220 pixels max on my machine to about 360 pixels before the performance dropped.
Some jump noises would be nice, but the code is very impressive.
Thanks RyanC! I'm very impressed on how you optimized this. I had originally thought that what I had done was about as much as Pico-8 could take. Also, I don't know why there isn't a character in mine, honestly...
EnzoGray, you commented out drawing sprite 32 (the white character) in your original code.
I'm pretty sure there are more code optimizations that can be done but I don't know enough about Lua to be able to start theorizing about it much at the moment.
In general you want to avoid creating/destroying objects as much as possible (reuse is generally more efficient), lookup tables can be faster than raw calculation at the cost of memory (in this case I don't think there is enough calcuations to warrant it), short-circuit multiple chained if/and/or statements with the condition most likely to occur first, also if you're absolutely certain variables won't change then you can hardcode them (as that is quicker than looking them up).
I did a couple of minor changes and bumped the max number of pixels up to 400 so there is still room for more.
When I read that I was working on a sand-dropper thing that could really use some optimization, I'm gonna try implementing some of those techniques.
[Please log in to post a comment]