I made an asteroid video game, each asteroid breaking into hundreds of pieces, and those pieces breaking into hundreds of pieces. you can imagine how many fragments there are.
each fragment takes a random direction.
each fragment has its image (spr_fragment, x, y).
but image () is very slow when called many times, it goes down from 60fps to 5fps.
I forgot to say that each fragment must detect collision with ship bullets, to be destroyed when colliding with the ship’s bullet, and until they are destroyed they must move with image (spr_fragment, x, y). it is not a simple animation.
How can I render many fragments without it getting slow, without losing fps, processing?
why don’t use a simple animated gif or a video for this ? If you prepare some animations, you can keep the randomness appearance of your animation, and you don’t need to load a lot of images
Another idea : don’t calculate their position at each draw, it is actually useless. Around 24 frames / seconds is enough to make it smooth. You can do it like this :
I forgot to say that each fragment must detect collision with ship bullets, to be destroyed when colliding with ship bullet. it is not a simple animation.