Jump to content

  • Log In with Google      Sign In   
  • Create Account


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • This topic is locked This topic is locked
3 replies to this topic

#1 DarkHorseKnight   Members   -  Reputation: 143

Like
0Likes
Like

Posted 08 February 2012 - 02:37 PM

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

Sponsor:

#2 bombshell93   Members   -  Reputation: 198

Like
-1Likes
Like

Posted 08 February 2012 - 03:37 PM

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. //
}


#3 DarkHorseKnight   Members   -  Reputation: 143

Like
0Likes
Like

Posted 08 February 2012 - 05:52 PM

Thanks for the tip :D

#4 swiftcoder   Senior Moderators   -  Reputation: 9731

Like
0Likes
Like

Posted 09 February 2012 - 09:15 AM

Closed as duplicate. Continue discussion in the more active thread.

Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS