Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 1.21 KB | None | 0 0
  1. module testderelict.main;
  2.  
  3. import tango.io.Console;
  4. import derelict.sdl.sdl;
  5. import derelict.sdl.image;
  6.  
  7. const HEIGHT = 640;
  8. const WIDTH = 480;
  9.  
  10.  
  11. int main()
  12. {
  13.     SDL_Surface* screen = null, carre = null;
  14.     SDL_Rect position, positionCarre;
  15.    
  16.     position.x = 0;
  17.     position.y = 0;
  18.     positionCarre.x = (640/2) - (220/2);
  19.     positionCarre.y = (480/2) - (180/2);
  20.    
  21.     SDL_Init(SDL_INIT_VIDEO);
  22.     screen = SDL_SetVideoMode(HEIGHT, WIDTH, 32, SDL_HWSURFACE);
  23.     carre = SDL_CreateRGBSurface(SDL_HWSURFACE, 150, 100, 32, 0, 0, 0, 0);
  24.     SDL_FillRect(screen, null, SDL_MapRGB(screen.format, 255, 255, 255));
  25.     SDL_FillRect(carre, null, SDL_MapRGB(carre.format, 255, 0, 0));
  26.    
  27.     SDL_BlitSurface(carre, null, screen, &positionCarre);
  28.    
  29.     SDL_Flip(screen);
  30.     bool continuer = true;
  31.     SDL_Event event;
  32.     while(continuer)
  33.     {
  34.         SDL_WaitEvent(&event);
  35.         switch(event.type)
  36.         {
  37.             case SDL_QUIT:
  38.                 continuer = false;
  39.             break;
  40.             default:
  41.             break;
  42.         }
  43.         //Bounding box ici
  44.         SDL_FillRect(screen, null, SDL_MapRGB(screen.format, 255, 255, 255));
  45.         SDL_BlitSurface(carre, null, screen, &positionCarre);
  46.         SDL_Flip(screen);
  47.        
  48.        
  49.     }
  50.  
  51.     SDL_FreeSurface(screen);
  52.     SDL_FreeSurface(carre);
  53.     SDL_Quit();
  54.    
  55.    
  56.    
  57.  
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement