I'm adding some procedural-generated animation to my game and encountered problems with FPS.
Here is the ready-to-launch main.lua file that demonstrates the code that causes the problem.
It does exactly what is happening in this GIF. Human-shaped figures crumble into particles that are forced by gravity. The GIF is recorded from simulator so there is stable 30 FPS.
These figures consist of ~40 pieces each and each figure calculates the positions of its particles separately. Everything works fine on my Mac but in the real Playdate device, I see degradation of FPS during this process. It's fine when I have only 1-2 but it slows down starting from 3 figures.
I've made several optimizations:
- removed colliders from particles and used simple custom logic
- use simple variables instead of points and vectors
- each figure calculates its pieces (so particles themselves are "dumb")
- to ensure that the problem is not in creating the objects I have them already created and check only the "animation".
Ideally, I would like to have some random initial speeds for each particle in each figure.
So I have 5 * 40 ~ 200 simultaneously and independently moving objects. Is it even possible with Playdate's hardware?
Thank you in advance!