Ok, so maybe it does look like an astronaut standing on a hill of chocolate chip cookies[grin]
So yeah, this is my new game project. This screenshot doesn't show off the coolest part of the game yet, animation. That's right, the player sprite is now almost completely animated (except for a jumping frame).
I did come across an interesting bug when writing the animation code, though.
See, to animate my player character, I first created a multi-dimensional array of bitmaps to hold the sprites:
SDL_Surface *player_sprite[2][MAX_FRAME];
MAX_FRAME = 3, by the way.
The first dimension holds the sprites for each direction the player might be facing, which for this game is only right and left. The second dimension holds the max amount of sprite frames in the animation.
Now there was my animation code:
if(m_FrameCount >= m_FrameDelay){ if(m_CurFrame >= MAX_FRAME) m_CurFrame = 0; else m_CurFrame++; m_FrameCount = 0;}
When I ran the program the animation would spin when the player ran right and flicker when it ran left. I thought this was really odd, and it took me quite awhile to find the problem.
Turns out I was trying to access an index pass the bounds of the array. I quickly fixed the problem and now it looks great. However, I would've expected a bug like this to crash the program with an access violation, but it didn't even crash it in the debugger. Does VC++ perform some sort of bounds checking or something like that? that is the only thing I can think of.
Also, does anyone know how to make a SDL program wait for V-Sync? I'm trying to make the scrolling on the game smoother.
Anyways, I'll keep working at it, but it is coming along very nicely so far.
For example, firstly you could separate a sprite from it's animations. Hence, you would have an animation class and a sprite class, the latter of which will contain a list (use SC++L!) of the former (perhaps stored in a std::map so each may be associated with a descriptive name rather than a non-descriptive integer).
Secondly, an animation might consist of a list of frames. A frame, furthermore, might have properties such as image handle (or pointer, or whatever) and display time (this way you can make certain frames display longer for more realistic animations).
Anyway, other than these minor suggestions, it's looking good!