Thank you for your advices
I was well aware of this issue and I rewrote my engine using tiles only. It was way faster but it made the blocks regeneration difficult. I tried to store their timer in an array but it was kind of glitchy.
So I tried another way, by keeping using blocks but storing them in an array as using sprites provided me more flexibility.
It's quite effective : http://canapin.com/construct/tolilo/07/
I also made new block frames so my map is more "precise".
The issue I'm facing now is that when there are a lot of projectiles on the screen, it starts to slow down when looking for collisions with blocks.
My guess is that because on the "projectile
collision with block
" event, it iterates over all the blocks. If there are 10 projectiles on the screen, it iterates over 10*4000 blocks.
I have two ideas.
1) Instead of looking on collisions with blocks, I could compare the projectile with block coordinates in my array. But that would be kind of complex, especially with blocks which don't have a square hitbox. Plus, I would like to put a behavior physic on blocks (not movables) and projectiles, and I'm pretty sure it will have terrible performances.
2) Going back to tiles and try to :
a) make my array containing timer work
b) using invisible sprites containing a timer for each destroyed tile all over the holes created, and remove these sprites when the timer ends
And hoping that the physic behavior will work smoothly when using tiles instead of blocks.
If you have an advice regarding these solutions, I'm interested in.