summaryrefslogtreecommitdiff
path: root/noncore/games/sfcave-sdl/animatedimage.cpp
Side-by-side diff
Diffstat (limited to 'noncore/games/sfcave-sdl/animatedimage.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/sfcave-sdl/animatedimage.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/noncore/games/sfcave-sdl/animatedimage.cpp b/noncore/games/sfcave-sdl/animatedimage.cpp
index d9d6ff6..441c647 100644
--- a/noncore/games/sfcave-sdl/animatedimage.cpp
+++ b/noncore/games/sfcave-sdl/animatedimage.cpp
@@ -1,13 +1,13 @@
#include "SDL.h"
#include "SDL_image.h"
#include "constants.h"
#include "animatedimage.h"
-AnimatedImage :: AnimatedImage( QString file, int nFrames )
+AnimatedImage :: AnimatedImage( string file, int nFrames )
{
nrFrames = nFrames;
currentFrame = 0;
// Load image
image = IMG_Load( (const char *)file.c_str() );
@@ -16,15 +16,12 @@ AnimatedImage :: AnimatedImage( QString file, int nFrames )
nrFrames = 0;
image = 0;
return;
}
SDL_SetColorKey(image, SDL_SRCCOLORKEY | SDL_RLEACCEL, SDL_MapRGB( image->format, 0, 0, 0 ) );
-// image = SDL_DisplayFormat( tmp );
-
-// SDL_FreeSurface( tmp );
frameWidth = image->w/nrFrames;
frameHeight = image->h;
}
AnimatedImage :: ~AnimatedImage()
{
@@ -44,12 +41,15 @@ bool AnimatedImage :: nextFrame()
return rc;
}
void AnimatedImage :: draw( SDL_Surface *screen, int x, int y )
{
+ if ( !image )
+ return;
+
SDL_Rect dst;
dst.x = currentFrame * frameWidth;
dst.y = 0;
dst.w = frameWidth;
dst.h = frameHeight;