123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- #include "menuFire.h"
- bool optionsFire::continuer=true;
- unsigned int optionsFire::difficulte=0;
- bool optionsFire::pleinEcran=false;
- SDL_Surface* optionsFire::level=0;
- int menuFire()
- {
- if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
- {
- printf( "Unable to init SDL: %s\n", SDL_GetError() );
- return 1;
- }
-
- atexit(SDL_Quit);
-
- SDL_WM_SetIcon(SDL_LoadBMP("Images/Icone Prog D.bmp"),NULL);
- SDL_Surface* ecran = SDL_SetVideoMode(640, 480, 16,SDL_HWSURFACE|SDL_DOUBLEBUF);
- SDL_WM_SetCaption("Fire !!!",NULL);
- if ( !ecran )
- {
- printf("Unable to set 640x480 video: %s\n", SDL_GetError());
- return 1;
- }
- int quit(0);
- SDL_ShowCursor(SDL_ENABLE);
-
- SDL_Surface* bmp = SDL_LoadBMP("Images/Hiver.bmp");
- SDL_Surface* bmpDeux = SDL_LoadBMP("Images/Collines.bmp");
- SDL_Surface* bmpTrois = SDL_LoadBMP("Images/Soleil.bmp");
- SDL_Surface* bmpSelect = bmp;
- int choice(0);
- SDL_Surface* indication = SDL_LoadBMP("Images/MenuFire.bmp");
- SDL_SetColorKey(indication,SDL_SRCCOLORKEY,SDL_MapRGB(indication->format,255,255,255));
- if (!bmp)
- {
- printf("Unable to load bitmap: %s\n", SDL_GetError());
- return 1;
- }
-
- SDL_Rect position; SDL_Rect positionIndication;
- position.x = 0; positionIndication.x = 160;
- position.y = 0; positionIndication.y = 120;
- bool done = false;
- while (!done)
- {
-
- SDL_Event event;
- SDL_WaitEvent(&event);
-
- switch (event.type)
- {
-
- case SDL_QUIT:
- optionsFire::continuer=false;
- done = true;
- quit = 2;
- break;
-
- case SDL_KEYDOWN:
- switch(event.key.keysym.sym)
- {
- case SDLK_ESCAPE:
- done = true;
- break;
- case SDLK_LEFT:
- optionsFire::pleinEcran=false;
- break;
- case SDLK_RIGHT:
- optionsFire::pleinEcran=true;
- break;
- case SDLK_UP:
- if (choice<2)
- {
- choice++;
- }
- break;
- case SDLK_DOWN:
- if (choice>0)
- {
- choice--;
- }
- break;
- }
- break;
- }
-
- switch(choice)
- {
- case 0:
- bmpSelect=bmp;
- break;
- case 1:
- bmpSelect=bmpDeux;
- break;
- case 2:
- bmpSelect=bmpTrois;
- break;
- }
-
-
- SDL_FillRect(ecran, 0, SDL_MapRGB(ecran->format, 0, 0, 0));
-
- SDL_BlitSurface(bmpSelect, 0, ecran, &position);
- SDL_BlitSurface(indication, 0, ecran, &positionIndication);
-
-
- SDL_Flip(ecran);
- }
-
- optionsFire::level=bmpSelect;
- optionsFire::difficulte=choice;
-
- if (!(bmpSelect==bmp))
- {
- SDL_FreeSurface(bmp);
- }
- else if(!(bmpSelect==bmpDeux))
- {
- SDL_FreeSurface(bmpDeux);
- }
- else if (!(bmpSelect==bmpTrois))
- {
- SDL_FreeSurface(bmpTrois);
- }
- SDL_FreeSurface(indication);
-
-
- printf("Exited cleanly\n");
- return quit;
- }
|