Problem with drawing sprite (SDL)

I'm not succeeding in drawing a sprite. I use the function:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
void drawSprite(SDL_Surface* imageSurface, SDL_Surface* screenSurface, int srcX, int srcY, int dstX, int dstY, int width, int height)
{
	SDL_Rect srcRect;
	srcRect.x = srcX;
	srcRect.y = srcY;
	srcRect.w = width;
	srcRect.h = height;

	SDL_Rect dstRect;  
	dstRect.x = dstX;
	dstRect.y = dstY;
	dstRect.w = width;  // This is actually ignored by SDL_BlitSurface.
	dstRect.h = height; // This is actually ignored by SDL_BlitSurface.
   
	SDL_BlitSurface(imageSurface, &srcRect, screenSurface, &dstRect);
		// fast blit from source to destination.  
		// ignores the -1 or -2  possible error codes.
}

Like this:
drawSprite(shot, screen, 0, 0, sPosX, sPosY, 8, 8);
after defining shot using
shot=SDL_LoadBMP("./shot.bmp");

The file definitely exists, otherwise the program would crash (I haven't added verification of a correct load.)

It's working perfectly - no errors whatsoever, but the shot isn't being displayed.

Could it be that there's an error while blitting?
Are you updating the screen with SDL_UpdateRect()?
No, with SDL_Flip.
The updating is working perfectly, I've got another moving sprite there and there are no problems with that one.
You might want to do some error checking.

if( SDL_BlitSurface( /*arguments*/ ) == -1 )
throw SDL_GetError();
Could possibly be the order your displaying in. Or the shot itself - is it under the object your shooting from and not updating its x and y position so you never see it move?
It's working now, I was drawing the shot AFTER updating the display!
Thanks for the help anyway.
All is good - main thing is it's working now :)
Topic archived. No new replies allowed.