how to blit another image onto another

Ive got to make this mini game with the whole shabang main menu, quit, help etc.

So i need to start up with the main image and have start and help and if the user hits down or up key the image should blit to the next one...basically placing an arrow where he is going....


#include <SDL.h>
#include <iostream>
using namespace std;

int main (int argc, char** argv)
{
/*-----------------------------------
Initialisation
-----------------------------------*/

SDL_Surface* screen;
SDL_Surface* final;
SDL_Surface* plain;
SDL_Surface* Start;
SDL_Surface* Howtoplay;
SDL_Event evt;
bool isRunning;


/*-----------------------------------
Variable Init
-----------------------------------*/

SDL_Init(SDL_INIT_EVERYTHING);
screen = SDL_SetVideoMode(640,480,32,SDL_HWSURFACE);
final = SDL_LoadBMP("main title.bmp");
isRunning = true;


/*-----------------------------------
Game Loop
-----------------------------------*/


while(isRunning)
{

/*-----------------------------------
Event Loop
-----------------------------------*/
while(SDL_PollEvent(&evt)){

if(evt.type == SDL_QUIT){
isRunning = false;
}
if(evt.type == SDL_KEYUP){
if(evt.key.keysym.sym == SDLK_RETURN){
SDL_BlitScreen(Start,NULL,screen,NULL);
}
}
}

/*-----------------------------------
Update game world
-----------------------------------*/
SDL_Flip(screen);

/*-----------------------------------
Update Drawing
-----------------------------------*/
SDL_BlitSurface(final,NULL,screen,NULL);
SDL_Flip(screen);
}

/*-----------------------------------
Clean Up
-----------------------------------*/
SDL_FreeSurface(final);
SDL_Quit();
return 0;

}


so as you can see the SDL loads up main title.bmp and when i hit right arrow i should change it to start. but it doesnt work

any fix?
Does this help?

http://www.cplusplus.com/forum/windows/89212/#msg479846

To blit an image on top of another one, you just have to blit them sequentially in the order you want, from furthest back all the way to the foreground. So whichever you blit second will appear over the previous one, depending on the order you blit them.

so what the actual code?
Like this:

1
2
3
4
5
6
7
8
9
10
11
SDL_Surface *background = NULL;
SDL_Surface *foreground = NULL;
SDL_Surface *screen = NULL;

background = SDL_LoadBMP("background.bmp");
foreground = SDL_LoadBMP("foreground.bmp");

SDL_BlitSurface(background,NULL,screen,NULL);
SDL_BlitSurface(foreground,NULL,screen,NULL);

SDL_Flip(screen);


See:http://www.lazyfoo.net/SDL_tutorials/lesson02/index.php
Topic archived. No new replies allowed.