I have created two images that are supposed to be part of a character's animation cycle, and I want to rapidly switch between the two images, like a run cycle. However, just doing this makes the image change way too quickly, and adding a delay with Sleep() would slow down the whole program so i'm stuck as to how i would do it
The key is measuring time without delaying the program. A timer will work for this, as will al_wait_for_vsync, or simply al_get_time.
Decide the duration of the animation in seconds, determine how many frames you have and then to get the current animation frame, use fmod.
[edit]I was distracted and Edgar send it before me, but I think mine is simpler.[/edit]
Keep track about how many time the animation frame is on screen:
This all works, how would i modify it to happen when the character is moving in a specific direction?
Not sure what do you mean...
well i've made it so that when you change direction, the character does the opposite animation but the problem is a huge delay between pressing the button and the character actually moving.
Without actual code is hard to say. Maybe you should take a look to the Allegro Vivace tutorial.