summaryrefslogtreecommitdiff
path: root/noncore/games/sfcave-sdl/animatedimage.cpp
authorandyq <andyq>2003-01-21 20:37:00 (UTC)
committer andyq <andyq>2003-01-21 20:37:00 (UTC)
commit0a6563fcc2f49857c581d9def24407a3a4ef526c (patch) (side-by-side diff)
treef1b82a4bd7582ef2cb722cffb87eecff1e1f96e6 /noncore/games/sfcave-sdl/animatedimage.cpp
parent50b5915b48fc5cbacf23e4d2b75d7a266f141a4a (diff)
downloadopie-0a6563fcc2f49857c581d9def24407a3a4ef526c.zip
opie-0a6563fcc2f49857c581d9def24407a3a4ef526c.tar.gz
opie-0a6563fcc2f49857c581d9def24407a3a4ef526c.tar.bz2
Clean up of code - fixed memory leaks (most of them) and added new custom config menu
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;