diff --git a/travail_de_groupe/chef_oeuvre/src/player.c b/travail_de_groupe/chef_oeuvre/src/player.c index 622717bb2c8d3520eb05bc00fbb341cad3b96541..865f3a155734ad29523334da798fcb11935dac56 100644 --- a/travail_de_groupe/chef_oeuvre/src/player.c +++ b/travail_de_groupe/chef_oeuvre/src/player.c @@ -126,22 +126,22 @@ void manageMovement(){ player.isMoving = 1; player.direction = PLAYER_UP; } - if(keys[PLAYER_DOWN]){ + else if(keys[PLAYER_DOWN]){ moveDownPlayer(); player.isMoving = 1; player.direction = PLAYER_DOWN; } - if(keys[PLAYER_LEFT]){ + else if(keys[PLAYER_LEFT]){ moveLeftPlayer(); player.isMoving = 1; player.direction = PLAYER_LEFT; } - if(keys[PLAYER_RIGHT]){ + else if(keys[PLAYER_RIGHT]){ moveRightPlayer(); player.isMoving = 1; player.direction = PLAYER_RIGHT; } - player.isMoving = 0; + else player.isMoving = 0; } int selectStateHover(){ diff --git a/travail_de_groupe/chef_oeuvre/src/render.c b/travail_de_groupe/chef_oeuvre/src/render.c index eafdaabb174150c383ffe7f237ef76480de2c294..2c4c73a7df40b1937c808341914083bcff9ad1aa 100644 --- a/travail_de_groupe/chef_oeuvre/src/render.c +++ b/travail_de_groupe/chef_oeuvre/src/render.c @@ -153,9 +153,13 @@ void drawPlayer(){ rect.x = player.x + (screenDimension.w - (MAPSIZE * CELLSIZE)) / 2; rect.y = player.y ; SDL_Rect destRect = {32 * (SDL_GetTicks()/200%6), 0, 32, 32}; - SDL_Texture * drawTexture = (player.isMoving) ? (playerTexture):(playerIdleTexture); int flip = (player.direction == PLAYER_LEFT) ? (SDL_FLIP_HORIZONTAL) : (SDL_FLIP_NONE); - SDL_RenderCopyEx(renderer, playerTexture, &destRect, &rect, 0, NULL, flip); + if (player.isMoving){ + SDL_RenderCopyEx(renderer, playerTexture, &destRect, &rect, 0, NULL, flip); + } + else { + SDL_RenderCopyEx(renderer, playerIdleTexture, &destRect, &rect, 0, NULL, flip); + } } void drawBackgroundSides(){