Archived

This topic is now archived and is closed to further replies.

FlorianapoliS

Help with speed of animations.

Recommended Posts

Hey, I've finished my pong game, and I've decide to move to a sort of action/adventure game similar to zelda. The only problem I'm having so far is that the animations of the character walking are to quick. heres the code:
    
  if(key[KEY_DOWN])
{

check_down(); //checks whether or not there is a wall in the way.


//gets animation state


if (frame_number == 1)
    {
     frame_number = 0;
    } 
     else
    {
     frame_number = 1;
    }

}
  
it gets them from an allegro .dat file using this
      
   draw_sprite(buffer, man_picture[frame_number].dat, man.x, man.y);
    
So if someone can tell me how to slow this down it would be a great help, thanks for your time. Edited by - FlorianapoliS on August 5, 2001 4:38:47 AM

Share this post


Link to post
Share on other sites
One way is to use static variables to keep track of the time since you last changed the frame of the animation. Every time the movement code is called, check if the time elapsed is greater than 0.25 seconds (or whatever time period you want between frame changes). If it is, change the frame and set the timer back to zero. If it''s not, do nothing.

Share this post


Link to post
Share on other sites
You have made a pong and now you want to make a Zelda?... hmmm... I think you should make some tetris clone first, then pacman and then mario bros. after that you''ll have enough skills to strart doing a basic tile based RPG like Zelda....


but ok... go on if you feel like you can do it...

good luck!

jakovo

Share this post


Link to post
Share on other sites