Funny problem with SDL animations

Started by
3 comments, last by DeadXorAlive 18 years, 3 months ago
Ive made a spritebase class. I use Microsoft Visual 2003 .NET. Funny thing is, whenever a sprite has shown every frame in an animation, it dissapears. Whats almost even more funny (:P) is that this problem only occurs if I have the "Release" as the active configuration. If I have "Debug" it all works fine, although it seems to "flash" everytime it has done the animation. That is, dissappear and then, in the blink of an eye, reappear. Anyone knows what could be wrong? Its the same code thats in the executeable in both examples so I dont really know how to debug it. Please ask if I should put some or all of the files online.
Advertisement
I'll put up the source then. Anyone got the slightest idea of what could be wrong? Since its the same source in both cases, I dont really know how to debug. Feels like my c++ knowledge is quite useless now.

Debug
Release
Source

The initial player animation (yey for programmers art :P) has four frames. In the release compile configuration, it dissappears after four frames. In the debug on, it just "blinks" after four frames, dissappears and then rappidly reappears. I dont want any of that to happen. :P The release compile is quite useless and the effect in the debug one isnt pretty.

Ive also included the entire source, project files and all that kind of stuff. Im desperaty, hasnt anyone seen anything like this before?
Hi, I think it might be because there's a vector to keep track of the total number of frames (right? I didn't really get the purpose of that vector), while a 0-indexed integer keeps track of the current frame.
So when there are four frames, vector.size() gives 4, yet the currentframe integer is 3, failing to reset the animation.

I don't know if that solves the problem though, haven't tried compiling.

EDIT: this solves it. When I compiled it, it crashed instead of just going blank after the fourth frame. I guess that's because this currentframe integer is used as an index for the position in the image, a sprite-sheet?
Btw, it was nice looking at this code, just to compare how you solved the problems that come with making this kind of classes and what features you include.

[Edited by - DeadXorAlive on January 4, 2006 5:23:39 AM]
Dead on! Thanks a bunch, such a simple error. I wonder why it still keeps going altough I blit from out of bounds on a SDL_Surface*. Well I suppose thats why they call it debug compile. :P

What was you like in the code? :S Always nice to hear that, but no one has ever said something like that before :P. What was it that was so good?

Oh, and big rating++ to you!
Quote:Original post by Mizipzor
Dead on! Thanks a bunch, such a simple error.(...)

Some of those simple errors can drive me crazy, sometimes spending an hour to find a misplaced ;. But it helps to notice one gets better at spotting errors and finding ways to avoid them.

Anyway, I wrote something similar to your sprite classes, but on a somewhat lower level (of abstraction). Currently I'm learning OpenGL and I'll try to 'port' these classes to that API.
(Take this as something very subjective please:) I liked in your code that you coded something quite complete, now you are (almost) ready i think to make some games with it. I or other people might still have some critique (that vector bugs me, why?), but that doesn't matter. You can always reiterate the process and perfect the classes you have.
The thing is, IMO you get better just by coding over and over. Now I have just some sprite classes, about 25% or something of the functionality you have, because i spent lots of time coding them. I seem to get sucked into coding 'just those sprites', instead of coding them as a useful tool to make a game with. I think you have done that better.

This topic is closed to new replies.

Advertisement