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
Time to give our comets the old upgrade. This video really has an impact on how the game looks.
Full source can be found here.
where’s the video
What do you mean?
I’ve run into a pretty weird behaviour with this tutorial.
I’m a beginner in c++, but i was able to do all the other tutorials without difficulties.
Here, when i try to compile the code (the one linked on this very post), it compiles properly (debug & release), but crashes as soon as a comet appears (kind of as if i forgot to put the .png)
If i run the the .exe directly from explorer, it still crashes.
However, if i close VC++, and then run the .exe, everything runs fine.
This is really confusing me, any idea of what might be happening ?
Note : Windows XP / VC++ express. Done
Well, the .exe would fail of te .png was not in the same folder. Chances are, if your program is crashing, then the png is in the wrong spot. Run it with VS open and when the app crashes, mouse over the comet image variable (before you stop the program). If it’s value is something like 0x0000000 then it did not load correctly
Thanks for answering Mike.
Indeed when running from VS in debug mode the value of the image variable is 0×0000000. It only happens with asteroids image (spaceship & explosion load fine).
If i resize “asteroid-1-96.png” so that it’s 50% smaller (1009 x 336 instead of 2016 x 672), it loads perfectly (the animation is screwed, of course – but it loads, showing that the system finds the file).
So it would seem that on my machine, Allegro can’t load images above a certain threshold.
But if i launch the executable AFTER closing visual studio, then everything works like a charm.
It appears this problem is not so common, couldnt find anything on google. Maybe i should report this on ALlegro forums ?
Direct link to comet sprite sheet:
Edit by Mike Geig: Link removed. The link was directly to the image and gave no credit to the original author.
Oh I thought the credit you gave in the video was enough.
Hey Mike! Love the tutorials! Absolutely amazing. One thing though, this piece of code has been confusing me:
int fx = (comets[i].curFrame % comets[i].animationColumns) * comets[i].frameWidth;
I get the fy variable, but this one doesn’t make sense to me… Shouldn’t it only animate the second frame when curFrame = 21 (the animationColumns)? Wouldn’t that cause a delay?
Strike that last comment. I just forgot how the modulus functioned worked for a second.
Great video this really made some awesome game after all. The graphics was neat. Mike, you rock!! 😀