Puntoinfinito

Clase 4 SDL

May 5th, 2013
608
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. //Declarar librerias
  2.  
  3. #include <SDL/SDL.h>
  4.  
  5. int main() {
  6.  
  7.     //Inicilización
  8.     SDL_Surface* hello = NULL;
  9.     SDL_Surface* screen = NULL;
  10.  
  11.     SDL_Rect posicion_imagen;
  12.    
  13.     posicion_imagen.x = 50;
  14.     posicion_imagen.y = 50;
  15.  
  16.    
  17.    
  18.  
  19.     int i = 0;
  20.  
  21.     //Comenzar SDL
  22.     SDL_Init( SDL_INIT_EVERYTHING );
  23.  
  24.     //Set up de variables
  25.     hello = SDL_LoadBMP( "hello.bmp" );
  26.     screen = SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE );
  27.  
  28.     while (true) {
  29.  
  30.         i++;
  31.  
  32.         posicion_imagen.x = posicion_imagen.x + 10;
  33.         posicion_imagen.y = posicion_imagen.y + 10;
  34.  
  35.         SDL_BlitSurface( hello, NULL, screen, &posicion_imagen);
  36.  
  37.         SDL_Flip( screen );
  38.         SDL_Delay( 10 );
  39.  
  40.         if ( i > 100 ) {
  41.             SDL_FreeSurface( hello );
  42.             SDL_Quit();
  43.         }
  44.  
  45.     }
  46.    
  47.     return 0;
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment