Hi, I'm new to c++ and have made it far enough to start building a game in SDL (beginning to anyway) I have read a lot of tutorials and can't figure this one out.
In the codes below, I can't move my sdl_surface(image) up, down, left, or right, without it getting cut off by an invisible 256,64 box. Help please? thanks.
// Part of the screen we want to draw the sprite to
SDL_Rect destination;
destination.x = 100;
destination.y = 0;
destination.w = 256;
destination.h = 64;
// Part of the screen we want to draw the sprite to
SDL_Rect destination2;
destination.x = NULL;
destination.y = NULL;
destination.w = NULL;
destination.h = NULL;
You're using SDL_Flip wrong. I don't know what you expect it to do there, but it isn't doing it.
SDL_Flip basically takes what you drew to the screen surface and makes it so it is actually displayed on screen. Since you're not [explicitly] doing any double buffering, it likely has the same effect as SDL_UpdateRect.
So basically, you flip the screen surface, not an offscreen surface. Flipping 'image' doesn't make any sense.
You probably want to do this:
1 2 3 4 5 6 7
SDL_BlitSurface(image, &source, screen, &destination);
SDL_Flip(screen);
// get rid of SDL_UpdateRect
SDL_FreeSurface(image);