12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #include <iostream>
- #include <SDL/SDL.h>
- #include "AnimRoue/AnimaRoue.h"
- int main ( int argc, char** argv )
- {
- /// [1] Démarrage
- // [1.1] Démarrages SDL
- if ( SDL_Init( SDL_INIT_VIDEO ) < 0)
- {
- std::cout << "Impossible d'initialiser la SDL: " << SDL_GetError() << std::endl;
- return 1;
- }
- // [1.2] Préparation de fermeture
- atexit(SDL_Quit);
- // [1.3] Para-fenêtre
- SDL_WM_SetCaption("Test animations", 0);
- /// [2] Préparation des composants
- // [2.1] Préparation de la fenêtre
- SDL_Surface* screen = SDL_SetVideoMode(640, 480, 16,
- SDL_HWSURFACE|SDL_DOUBLEBUF);
- if ( !screen )
- {
- std::cout << "Unable to set 640x480 video: " << SDL_GetError() << std::endl;
- return 1;
- }
- // [2.2] Préparation
- AnimaRoue maRoue;
- /// [3] Boucle principale
- bool done = false;
- while (!done)
- {
- // [3.1] Gestion évènements
- 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;
- break;
- } // end switch event type
- } // end of message processing
- // [3.2] Calculs
- // [3.3] Dessin des composants
- SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 255, 255));
- maRoue.coller(screen, 20, 40);
- SDL_Flip(screen);
- } //fin bcl principale
- ///[4] Destruction des composants
- std::cout << "Aucune erreur détectée." << std::endl;
- return 0;
- }
|