123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- #include <cstdlib>
- #include <SDL/SDL.h>
- #undef main
- #include "LaunchCircle.h"
- int main ( int argc, char** argv )
- {
-
- if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0 )
- {
- printf( "Unable to init SDL: %s\n", SDL_GetError() );
- return 1;
- }
-
- atexit(SDL_Quit);
-
- SDL_Surface* screen = SDL_SetVideoMode(640, 480, 16,
- SDL_HWSURFACE|SDL_DOUBLEBUF);
- if ( !screen )
- {
- printf("Unable to set 640x480 video: %s\n", SDL_GetError());
- return 1;
- }
-
- LaunchCircle cercle(200, SDL_MapRGB(screen->format,255,128,0), 360, 150);
- int verrou(0);
- bool up(false);
- bool down(false);
-
- bool done = false;
- while (!done)
- {
-
- SDL_Event event;
-
- while(SDL_PollEvent(&event))
- {
- switch (event.type)
- {
-
- case SDL_QUIT:
- done = true;
- break;
-
- case SDL_KEYDOWN:
- {
-
- if (event.key.keysym.sym == SDLK_ESCAPE)
- done = true;
- if(event.key.keysym.sym == SDLK_UP)
- up=true;
- if(event.key.keysym.sym == SDLK_DOWN)
- down=true;
- break;
- }
- case SDL_KEYUP:
- {
- if(event.key.keysym.sym == SDLK_UP)
- up=false;
- if(event.key.keysym.sym == SDLK_DOWN)
- down=false;
- break;
- }
- }
- }
-
- if (up)
- verrou++;
- if(down)
- verrou--;
-
-
- SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 140, 128, 128));
- cercle.afficher(320,240,verrou,screen);
-
-
-
- SDL_Flip(screen);
- }
-
- printf("Exited cleanly\n");
- return 0;
- }
|