Is drawing faster in C than in Lua? (any tips for animated tiles updating almost every frame)

If you're just using the image:draw call in Lua is doing the equivalent in C faster? I am looking for ways to speed up drawing to make animated tiles (flowers, waterfall, etc.). Worst case drawing a ~12 by ~7 screen of 32x32px tiles every frame is already slow so I'm worried to even write up the logic that would decide what and where since I'm already near the 30fps line on the actual hardware plus collision and what not later. I have tried changing tilemap indexes and drawing to another image but it all seems slow in Lua at least.

In general C is faster, though I have only worked in Lua. I bet there are Lua optimizations you could do.

I'm OK with my framerate but I'd also like better! So something I'm considering is updating certain things every OTHER frame (or less), making less work per frame and allowing other changes to be faster.

And one thing I'm already doing: only drawing the parts of the screen that change. When I scroll, I copy the screen buffer, shift it, and now I just have to draw one strip of new imagery.

It depends how many tiles you need to have changing at once, though. The fewer the better! If flowers change rarely and straight rivers every 4th frame, maybe that lets waterfalls change every frame, say.

1 Like