   How do I SDL_Blit/SDL_Flip my menu the correct way? (Images shown inside)
  How do I make my main menu to show up in the correct way?I wanted my main menu to have the yellow arrow to move up and down without showing both arrows.A bit at the top (Notice that it's closer to the "Press Start" text.)A bit at the bottom (Notice that it's farther away.)But, I don't want my arrow(s) to appear like this below.Here's the code:#include "Animate.h"#include "Menu.h"#include <SDL.h>Menu::Menu(){arrow = IMG_Load("../Temp2/sprite/Selection.gif");Cursor.x = 0;Cursor.y = 0;Cursor.w = 10;Cursor.h = 10;Destination.x = 20;Destination.y = 80;}int Title(SDL_Surface* screen, SDL_Surface* intro){SDL_Event e;Menu Main;bool quit = false;bool unlock = false;while (quit != true){while (SDL_PollEvent(&e)){if (e.type == SDL_KEYDOWN){switch (e.key.keysym.sym){case SDLK_RETURN:unlock = true;break;case SDLK_UP:if (unlock == true){Main.setDestination(20, 80);SDL_BlitSurface(Main.getArrowSurface(), &Main.getCursorSize(), intro, &Main.getDestination());SDL_Flip(intro);}break;case SDLK_DOWN:if (unlock == true){Main.setDestination(20, 100);SDL_BlitSurface(Main.getArrowSurface(), &Main.getCursorSize(), intro, &Main.getDestination());SDL_Flip(intro);}break;case SDLK_x:unlock = false;break;case SDLK_z:return 0;case SDLK_ESCAPE:return -1;}}if (e.type == SDL_QUIT){return -1;}}SDL_BlitSurface(intro, NULL, screen, NULL);SDL_Flip(screen);}return 0;}SDL_Surface* Menu::getArrowSurface(){return arrow;}SDL_Rect Menu::getCursorSize(){return Cursor;}SDL_Rect Menu::getDestination(){return Destination;}SDL_Rect Menu::setDestination(int x, int y){Destination.x = x;Destination.y = y;return Destination;}
  Generally speaking, when doing graphics you redraw everything every frame and flip every frame. If you do that, the problem you have will go away. An alternative is to selectively draw over the old arrow but that gets awkward. The two buffers that you flip between are like chalk-boards - when you've drawn something on it, it'll stay there until you wipe it off and draw over it. It's easiest to wipe the whole thing and redraw the whole lot.Generally there's no reason to flip twice per iteration, like you're doing. There's also generally no reason to ever pass different values to SDL_Flip since you only have one screen to work with, which is whatever SDL_GetVideoSurface() returns.   ;  That means:1. SDL_Flip() should be used just once?2. Don't do SDL_Flip(intro)?3. Just blit the arrow surface once?4. How do you "wipe" the arrow off?   ;Quote:Original post by tom_mai78101That means:1. SDL_Flip() should be used just once?2. Don't do SDL_Flip(intro)?3. Just blit the arrow surface once?4. How do you "wipe" the arrow off?Assuming that intro is the image that has the "Press Start" text and the background gradient, a way to do it would be to blit that surface onto the screen and then blit the arrow on top of the screen.That way, every frame, you "wipe out" the screen with the background image (i.e., without the arrows) and then "add" the arrows.Something like this:int Title(SDL_Surface* screen, SDL_Surface* intro){SDL_Event e;Menu Main;bool quit = false;bool unlock = false;while (quit != true){while (SDL_PollEvent(&e)){if (e.type == SDL_KEYDOWN){switch (e.key.keysym.sym){case SDLK_RETURN:unlock = true;break;case SDLK_UP:if (unlock == true){Main.setDestination(20, 80);}break;case SDLK_DOWN:if (unlock == true){Main.setDestination(20, 100);}break;case SDLK_x:unlock = false;break;case SDLK_z:return 0;case SDLK_ESCAPE:return -1;}}if (e.type == SDL_QUIT){return -1;}}SDL_BlitSurface(intro, NULL, screen, NULL); SDL_BlitSurface(Main.getArrowSurface(), &Main.getCursorSize(), screen, &Main.getDestination());SDL_Flip();}return 0;};  Didn't work.   ;Quote:Original post by tom_mai78101Didn't work.Same result?Then, it seems to be something that modifies the "intro" surface somewhere else.  Or "intro" is not the background image.If you comment the second blit, are the arrows still shown?   ;  Do you mean "SDL_BlitSurface(Main.getArrowSurface(), NULL, screen, &Main.getDestination());"?Arrows won't show up.intro is the background image. screen is the video display.   ;Quote:Original post by tom_mai78101That means:1. SDL_Flip() should be used just once?2. Don't do SDL_Flip(intro)?3. Just blit the arrow surface once?4. How do you "wipe" the arrow off?Yes, yes, yes, and you don't. (Instead, you overwrite the whole screen each time first with the background, and then with the arrow.);  Alright, I finally got it working as expected.Thank you all! :)(Actually, thanks to summaky and Kylotan)