SO i figured it out. The reason why they were all in sync even with random delay
values is because they were all sharing the same global variables frame
and starttime
.
So instead, creating a structure of EXPLOSION
with the member variables frame
and starttime
and than using a vector to contain them all. After it just had to be iterated through.
The new code is here in case someone else comes along this problem.
//The structue to contain each explosions own frame and starttime variables
struct EXPLOSION
{
int frame;
int starttime;
};
//============================================================================
//
// Function calls
//
//==============================================================================
//animate and draw the sprite
for(int i = 0; i < 5; i++)
{
Sprite_Animate(explosions[i].frame, 0, 29, 1, explosions[i].starttime, rand() % 100);
Sprite_Draw_Frame(explosion, i * 100, 100, explosions[i].frame, 128, 128, 6);
}