As stated by the SDL documentation, if a SDL_Rect with negative coordinates is passed onto the SDL_BlitSurface function the image will be clipped accordingly. However, I tried setting an image with a negative position of (0,-300) and the image would be fixed at (0,0), not going out of the bounds of the window.
Here is a small snippet of the code:
image.SetPosY(-300);
image.Display();
void D_Image::SetPosY(int newPosY)
{
position.y = newPosY;
}
void D_Image::Display()
{
SDL_BlitSurface(image, NULL, window, &position);
}
image and position are an SDL_Surface and an SDL_Rect respectively. They are members of the class D_Image. What would be causing this problem? Do I need to make a cropping SDL_Rect and calculate it everytime I change the position?