diff --git a/travail_individuel/Belkhiri/Animate/run b/travail_individuel/Belkhiri/Animate/run index d11da59171258d7f1c8166ccb05a40a51ea0de24..fa53e56ec47a2779ed3be9de2e62aa87112c4e01 100755 Binary files a/travail_individuel/Belkhiri/Animate/run and b/travail_individuel/Belkhiri/Animate/run differ diff --git a/travail_individuel/Belkhiri/Animate/src/gest_event.c b/travail_individuel/Belkhiri/Animate/src/gest_event.c index 35dc133b17d8522f6f138296761a7f7e06e1ae9e..6ea787c62770e8aa2c9c6c6db3a68275570d2f8c 100644 --- a/travail_individuel/Belkhiri/Animate/src/gest_event.c +++ b/travail_individuel/Belkhiri/Animate/src/gest_event.c @@ -1,7 +1,7 @@ #include "gest_event.h" -void gestMenu(){ +void gestGame(){ SDL_Event event; while (SDL_PollEvent(&event)){ switch(event.type) @@ -33,8 +33,8 @@ void gestMenu(){ void *EventLoop(void *arg){ while(running){ switch(game_state){ - case MENU : gestMenu();break; - //case GAME : gestGame();break; + //case MENU : gestMenu();break; + case GAME : gestGame();break; default:printf("game state fault");break; } } diff --git a/travail_individuel/Belkhiri/Animate/src/render.c b/travail_individuel/Belkhiri/Animate/src/render.c index 9a5ac561eac85e739e082df7ca3d75e05a1ba8a4..a13f0a06a63727ee633be222fd2eac3aaea9e43b 100644 --- a/travail_individuel/Belkhiri/Animate/src/render.c +++ b/travail_individuel/Belkhiri/Animate/src/render.c @@ -13,6 +13,15 @@ SDL_Texture * character_walk_texture; SDL_Texture * character_jump_texture; SDL_Texture * character_attack_texture; +int character_walk_w; +int character_walk_h; + +int character_jump_w; +int character_jump_h; + +int character_attack_w; +int character_attack_h; + void CreateWindow(){ SDL_DisplayMode ScreenDimension; @@ -46,13 +55,32 @@ void CreateWindow(){ } -void Game(){ +void Game(int step){ + SDL_RenderClear(renderer); + SDL_Rect character_walk_rect; + + character_walk_rect.x = step; + character_walk_rect.y = 0; + character_walk_rect.w = 100; + character_walk_rect.h = 250; + + if (step < 100){ + SDL_Rect destRect; + destRect.w = character_walk_w/8; + destRect.h = character_walk_h; + destRect.x = (destRect.w * step)%character_walk_w; + destRect.y = 0; + SDL_RenderCopyEx(renderer, character_walk_texture, &destRect, &character_walk_rect, 0, NULL, SDL_FLIP_NONE); + } + SDL_RenderPresent(renderer); + SDL_Delay(100); } void MainLoop(){ CreateWindow(); + int step = 0; character_walk_surface = IMG_Load("Res/king_run_spritesheet.png"); character_jump_surface = IMG_Load("Res/king_jump_spritesheet.png"); @@ -66,6 +94,10 @@ void MainLoop(){ SDL_FreeSurface(character_jump_surface); SDL_FreeSurface(character_attack_surface); + SDL_QueryTexture(character_walk_texture, NULL, NULL, &character_walk_w, &character_walk_h); + SDL_QueryTexture(character_jump_texture, NULL, NULL, &character_jump_w, &character_jump_h); + SDL_QueryTexture(character_attack_texture, NULL, NULL, &character_attack_w, &character_attack_h); + unsigned int a = SDL_GetTicks(); unsigned int b = SDL_GetTicks(); double delta = 0; @@ -83,7 +115,8 @@ void MainLoop(){ b = a; switch (game_state){ case GAME: - Game(); + Game(step); + step++; break; } }