// **
// ** Name: draw
// ** Desc: draws the sprite on a surface
// **
int HSSprite::draw( HSSurface screen )
{
screen.changeRectW( image->w );
screen.changeRectH( image->h );
// **
// ** Palettized screen modes will have a default palette (a standard
// ** 8*8*4 colour cube), but if the image is palettized as well we can
// ** use that palette for a nicer colour matching
// **
if ( image->format->palette && screen.getSurface()->format->palette )
{
SDL_SetColors( screen.getSurface(), image->format->palette->colors, 0,
image->format->palette->ncolors );
}
// ** Blit onto the screen surface
if( SDL_BlitSurface( image, NULL, screen.getSurface(), &(screen.getRect()) ) < 0 )
fprintf( stderr, "BlitSurface error: %s\n", SDL_GetError() );
// ** Update modified rectangles
SDL_UpdateRect( screen.getSurface(), 0, 0, image->w, image->h );
return( 1 );
};
All right, I''ve limited my problem to this function. Oh, I forgot to mention that I''ve created Classes as I thought it would be a way to make my life easier for the purpose that I have. Anyways, the problems aren''t from the classes. It''s just that darn function.
On to the problem: The first time this function is called, it draws the sprite perfectly on the screen. The second time I call the fuction, it closes the app. I''m not sure why though as I''ve used this exact same function in 2 other projects and it worked fine. Again, as I''ve mentionned, I''ve spent quite a bit of time trying to figure it out but I can''t seem to pinpoint the problem.
"And that''s the bottom line cause I said so!"
Cyberdrek
Headhunter Soft
A division of DLC MultimediaResist Windows XP''s Invasive Production Activation Technology! "gitty up" -- Kramer /(bb|[^b]{2})/ that is the Question -- ThinkGeek.com