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
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.
If i use classes for player and comets.I can set the image as static ALLEGRO_BITMAP *image?
Yes, but you have to be careful. If one class object cleans up the memory by deleting the image, they all stop working. It can work but you must be careful when managing the memory.
OK.Thank you very much.
i had a question no matter what i do it seems that when I use the al_draw_bitmap_region function, my sprite sprite sheet seems to have continuous movement unlike how fluid the dragon moves in your tutorial.Essentially, I see at least 2 of my sprites in at a time moving forward in this continuous pattern…
Actually . I think the better question would be “Do the sprite sheets have to be perfect and do framewidth variable in the draw function have to match up twice? One being for the frame width and the other being where at the function will start drawing from the source.
Yes, that is correct. If they don’t line up, you will need a collection to store the various dimensions.
You must be cautious about that. However,
the interest rates are not worth consolidating because it either does not lower the rate or it even increases the rate.
A consolidate debt loans specialist will allow you to take bad credit consolidate debt loans.
The bottom line is that a person who finds themselves in this situation to begin with?
But it has to consolidate debt loans be wise in choosing the right one.
Students have to pay $12, 000.
My page: webpage
Hi, I love these videos!!! However, I have a question. All the videos have been fine untill now and I am having a problem with this one. I have an image and a sprite but whenever i build it just crashes at “al_convert_mask_to_alpha(sprite, al_map_rgb(0,0,0));”.
If I comment this out it just crashes at the next line:
If i comment out both lines the program opens without a problem.
All the variables etc are correct. It just crashes upon opening.
Any idea what the problem may be?