Jump to content
  • Advertisement
Sign in to follow this  
nsto119

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

This topic is 4621 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
Advertisement
Guest Anonymous Poster
post your code and let us take a look

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!