Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module testderelict.main;
- import tango.io.Console;
- import derelict.sdl.sdl;
- import derelict.sdl.image;
- const HEIGHT = 640;
- const WIDTH = 480;
- int main()
- {
- SDL_Surface* screen = null, carre = null;
- SDL_Rect position, positionCarre;
- position.x = 0;
- position.y = 0;
- positionCarre.x = (640/2) - (220/2);
- positionCarre.y = (480/2) - (180/2);
- SDL_Init(SDL_INIT_VIDEO);
- screen = SDL_SetVideoMode(HEIGHT, WIDTH, 32, SDL_HWSURFACE);
- carre = SDL_CreateRGBSurface(SDL_HWSURFACE, 150, 100, 32, 0, 0, 0, 0);
- SDL_FillRect(screen, null, SDL_MapRGB(screen.format, 255, 255, 255));
- SDL_FillRect(carre, null, SDL_MapRGB(carre.format, 255, 0, 0));
- SDL_BlitSurface(carre, null, screen, &positionCarre);
- SDL_Flip(screen);
- bool continuer = true;
- SDL_Event event;
- while(continuer)
- {
- SDL_WaitEvent(&event);
- switch(event.type)
- {
- case SDL_QUIT:
- continuer = false;
- break;
- default:
- break;
- }
- //Bounding box ici
- SDL_FillRect(screen, null, SDL_MapRGB(screen.format, 255, 255, 255));
- SDL_BlitSurface(carre, null, screen, &positionCarre);
- SDL_Flip(screen);
- }
- SDL_FreeSurface(screen);
- SDL_FreeSurface(carre);
- SDL_Quit();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement