diff --git a/main.c b/main.c index f4fff8f1d198cf3b952cf1dfadf5317443029741..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/main.c +++ b/main.c @@ -1,83 +0,0 @@ -#include <SDL.h> - - - -int main (int argc, char** argv) -{ - SDL_Init(SDL_INIT_VIDEO); - - SDL_Surface *ecran = NULL; - SDL_Surface *image = NULL; - - SDL_Rect position; - position.x = 0; - position.y = 0; - - SDL_Rect anim; - anim.h = 125; - anim.w = 95; - - int colorkey; - int gameover = 0; - int dirX = 0; - int dirY = 0; - - SDL_WM_SetCaption("Test", NULL); - ecran = SDL_SetVideoMode(500, 500, 32, SDL_HWSURFACE); - - SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 0, 0, 0)); - - image = SDL_LoadBMP("sprites.bmp"); - colorkey = SDL_MapRGB(ecran->format, 0, 255, 255); - SDL_SetColorKey(image, SDL_SRCCOLORKEY | SDL_RLEACCEL, colorkey); - - if(image == NULL) - return EXIT_FAILURE; - - SDL_Event event; - - - while(gameover == 0){ - - - SDL_PollEvent(&event); - - switch (event.type) { - case SDL_KEYDOWN: - switch (event.key.keysym.sym){ - case SDLK_ESCAPE: - gameover = 1; - break; - case SDLK_LEFT: - dirX = -1; - break; - case SDLK_RIGHT: - dirX = 1; - break; - case SDLK_UP: - dirY = -1; - break; - case SDLK_DOWN: - dirY = 1; - break; - } - - } - - position.x += dirX; - position.y += dirY; - dirX = 0; - dirY = 0; - SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 0, 0, 0)); - SDL_BlitSurface(image, &anim, ecran, &position); - SDL_Flip(ecran); - } - - - - - SDL_FreeSurface(image); - SDL_Quit(); - - return 0; -}