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.

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 on other sites
post your code and let us take a look

Share on other sites
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 on other sites
SDL_Rect offset;offset.x = x;offset.y = y;SDL_BlitSurface(source,NULL,destination,&offset);

SDL_BlitSurface stores the *clipped* rectangle in offset...
is that what you mean?

or is the image actaully stopping at the top left? (it doesnt on my SDL programs)

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 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.

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

• Forum Statistics

• Total Topics
628740
• Total Posts
2984470

• 12
• 25
• 11
• 10
• 16