I'm having some timing issues where I want certain animation to run slower than game loop (like every third time)
I'm not sure what the best way to do this is... I don't want to add Sleep() because I want the game loop to process as normal - getting clicks, keys etc
let's say I have some psuedo code like
but I want Sprite2 to only be updated every 3 game loops cycles and Sprite1 to update every 2 game loops
the MoveSprite functions are simply like x++,y++
I figure I can do
Sprite1.x+=2
Sprite2.x+=3
but that might screw up my movement
Another thing I thought about doing was having a unsigned long int that constantly increments each game loop and do
if (longint%2==0) MoveSprite1
if (longint%3==0) MoveSprite2
anyone else have any ideas or know the most common way to do this??
Thanks !
I'm not sure what the best way to do this is... I don't want to add Sleep() because I want the game loop to process as normal - getting clicks, keys etc
let's say I have some psuedo code like
- Code:
while (1)
{
resettimer();
surf->clear( 0 );
ProcessKeysAndClicks();
MoveSprite1();
MoveSprite2();
Draw();
while (msecs() < 30) {};
update();
}
but I want Sprite2 to only be updated every 3 game loops cycles and Sprite1 to update every 2 game loops
the MoveSprite functions are simply like x++,y++
I figure I can do
Sprite1.x+=2
Sprite2.x+=3
but that might screw up my movement
Another thing I thought about doing was having a unsigned long int that constantly increments each game loop and do
if (longint%2==0) MoveSprite1
if (longint%3==0) MoveSprite2
anyone else have any ideas or know the most common way to do this??
Thanks !