This post is a portion of Part 7 in my on going series about 2D Game Development using the Allegro 5 library. These posts are in course order. You can see all of the posts in this course by clicking the “2D Game Development” button at the top of this site.
- 7.0 – Sprites
- 7.1 – Bitmap Transparency in Allegro 5
- 7.2 – Basic Animation in Allegro 5
- 7.3 – Using Allegro 5 to Create a Sprite Sheet
- 7.4 – Sprite Sheet Animation in Allegro 5
Now that we have our sprite sheets made, all that’s left is to alter our animation demo to utilize them. This video will conclude part 7 and pave the way for our Sprite struct which we will introduce in Part 8
Full source can be found here

Very great tutorial, I’m really enjoying watching your lessons!
In your included source, on line 93 you wrote frameWidth, where frameHeight should be.
Hope to see more videos from you soon!
nice catch! Fixed it.
Sprite Sheet Animation in Allegro 4 or 5?
Couldn’t you divide the imageWidth by maxFrames to get the individual image width? imageHeight could be directly recieved from the sprite sheet. Although this only works for a sprite ‘strip’ in this case.
You also forgot to do al_destroy_timer(timer); so there will be a small memory leak from the timer.
Er, sorry, that sounded like I was just criticizing you. Your tutorials are great!
No problem, thanks for pointing it out
You could certainly do that, Of course, it will only work if there is no space at the end of your sprite sheet. Also, it assumes that the sprite images are alone on the sheet and it isn’t shared. The way I do it, you only need a numerical offset and it can work for any type of sheet.
And yes, I often accidentally forget to clean up my memory. I can just never seem to remember
Hey Mike,
You’re a Godsend! Thank you so much for these videos, I’ll be donating here before too long and you can be sure I’ll spread the word to my Comp Sci friends.