This post is a portion of Part 9 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.
- 9.0 – Revisiting Our Game
- 9.1 – Revisiting Our Game – The Player
- 9.2 – Revisiting Out Game – The Comet
- 9.3 – Revisiting Our Game – Explosions
In this video we replace our old graphical primitive ship with something a little more sleek. Pay attention to the layout of the sprite sheet and how we allow the user to control the animation based on key presses.
Full source can be found here.
why don’t you provide the sprite sheet, so we can follow along at home
I have answered this question a few times in the comments. They aren’t mine to give. I do, however, show you where I got them. Go download them on your own.
Man I really wish there would be things like this here in Venezuela. I would really love to get into the gaming business but it’s practically nonexistent here :/
Your tutorials are great tho keep up the good work!
I have been following along with the tutorials, however have been making a completely different game. Whenever I try to make my character move, the sprite sheet cycles through super fast and I’m not too sure on how to slow it down to a pace that actually fits the walking speed. Any ideas?
Also, these tuts are great 🙂
Pay attention to frameCount and frameDelay
How would I use the frameDelay when it’s cycling through the walking animations in the void MoveShipDown etc. I think I’m doing this completely wrong.
Assuming you wrote your code the same as mine, if you increase frameDelay the sprite animates slower.
You didn’t actually incorporate the frameDelay into the code. You said you only put it in there just in case. I’m kind of new at all this, so sorry about the 20 questions.
I just noticed what video you are on. Keep watching. I show how to animate comets in the next one and I cover the frame delay.
After trying the comet framedelay, it wouldn’t cycle through any of the sprites animations, would it be okay if I sent you my code, and if/when you get some spare time you could have a quick look over it?
Here’s the cropped and rotated spaceship image in case you don’t have proper software. The author on deviant art allows permission to use this even commorcially:
Edit by Mike Geig: Link removed. The link was directly to the image and gave no credit to the original author.
Help in my game only left and right buttons work but if I press up and down the ship won’t tilt. :/
ah it’s okay now I’ve solved the problem. 🙂
First thanks for the tutorial, but I have a question…
How can I create a walking cycle for RPG game characters like this one: http://i83.photobucket.com/albums/j295/woratana/097-Monster11.png
I was trying it a lot but couldn’t achieve it…
Thanks
Hey, I paused the video and went ahead a little bit. I did something different for resetting the player’s animation position than you. I simply reset the curFrame up in the key release portion of the code and it accomplished the same thing:
//Releasing the keys.
case ALLEGRO_KEY_UP:
keys[UP] = false; //The Up key is released.
ship.animationRow = 1;
break;
case ALLEGRO_KEY_DOWN:
keys[DOWN] = false; //The Down key is released.
ship.animationRow = 1;
break;
case ALLEGRO_KEY_LEFT:
keys[LEFT] = false; //The Left key is released.
ship.curFrame = 0;
break;
case ALLEGRO_KEY_RIGHT:
keys[RIGHT] = false; //The Right key is released.
ship.curFrame = 0;
break;
Just thought I should share an alternative way of doing it. I have my game behaving in the same manner you showed.
Hi Mike, or anyone who can help.
I have checked and rechecked my code but when I debug this I get the following error
“Unhandled exception at 0x0f46d26e in shooter.exe: 0xC0000005: Access violation reading location 0x00000014.”
I also tried the source code files that you provide and I still get the same error.
Any ideas?
I love this tutorial series btw!