Jump to content
  • Advertisement
Sign in to follow this  
DominicHughes

Animation is a blight and I can't figure it out ! help :(

This topic is 2497 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello I'm trying really hard to listen to the advice some people give but I generally don't want to do it a way that requires more annoying irritation and or emotional pain so I've been doing animation in SDL using interger counters like so


int timer = 0;
timer++;
if(timer == 1)
{
FRAME= 1;
}

if(timer == 2)
{
FRAME= 2;
}

if(timer == 3)
{
FRAME= 3;
timer = 0;
}


EnemyRect = StorageRect;
SDL_BlitSurface(Enemysprite[FRAME],NULL,Screen,EnemyRect);

and the problem is that everytime the code sets the timer to 0 it causes the sprite to dissappear for a few milliseconds and then shows again and repeats

and I have no Idea how to stop that from happening

could someone please tell me how to stop this from happening in the simplest and easiest way possible that doesn't require irritation


Thanks in Advance

Share this post


Link to post
Share on other sites
Advertisement
okay I don't know SDL but I can instantly see a problem,
if FRAME is always equal to timer or always relative to timer,
why not

FRAME = timer?

// or better yet //

FRAME++;


gets rid of the silly if statements.
even if the if statements are needed it'd look cleaner to use a switch statement

switch (timer)
{
case(0) : {FRAME = 0;} break;
case(1) : {FRAME = 1;} break;
case(2) : {FRAME = 2;} break;
// etc. etc. //
}

Share this post


Link to post
Share on other sites

This topic is 2497 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!