Sign in to follow this  

SDL_BlitSurface() setting the dest Rect's coords to 0...

This topic is 4403 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been having this problem for a while now. For some reason, when I blit a surface, if the X- or Y- coordinates are less than zero, the SDL_BlitSurface() function is setting them back to zero... this means that if, for example, the player fires a missile from the ship, it just stops dead at the top of the screen. I can't figure this out for the life of me, and I haven't seen any other games that are having this problem... any ideas?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
just to make sure...

make a function to blit like this

void apply(int x,int y,SDL_Surface* source, SDL_Surface* destination)
(
SDL_Rect offset;

offset.x = x;
offset.y = y;

SDL_BlitSurface(source,NULL,destination,&ofset);
}

Share this post


Link to post
Share on other sites
Well... I got it working, but I'm not sure WHY.

In the Sprite's Render() function, instead of blitting using the Sprite class's private Rect member for the dst, I dereferenced it and created a copy and used the copy for blitting... I don't really see why this would make a difference, though.

EDIT: Nevermind, it all made sense after I gave it a little thought.

Share this post


Link to post
Share on other sites

This topic is 4403 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this