diff --git a/objects/oPlayer/Create_0.gml b/objects/oPlayer/Create_0.gml index 1c94493..1bfc686 100644 --- a/objects/oPlayer/Create_0.gml +++ b/objects/oPlayer/Create_0.gml @@ -5,4 +5,5 @@ inv = 0; //timer invinsiblité indexImageInfo = 0; compteurFrames = 0; -attack = 10; \ No newline at end of file +attack = 10; +isAttack = false; // permet de savoir si le joueur a appuyé sur la touche attaquer ou pas \ No newline at end of file diff --git a/objects/oPlayer/KeyPress_74.gml b/objects/oPlayer/KeyPress_74.gml index f77a3e7..887bca0 100644 --- a/objects/oPlayer/KeyPress_74.gml +++ b/objects/oPlayer/KeyPress_74.gml @@ -1,10 +1,11 @@ // Attaque au corp à corp //jouer l'animation - - tailleEpee = 30; // à définir - checkCote = image_index / 8; // récupère où regarde le personnage - inst = noone; +isAttack = true; +compteurFrames = 0; +tailleEpee = 30; // à définir +checkCote = image_index / 8; // récupère où regarde le personnage +inst = noone; if (sprite_index == sPlayerRun) { if (checkCote <= 1) { diff --git a/objects/oPlayer/Step_0.gml b/objects/oPlayer/Step_0.gml index 054dc3e..47012d5 100644 --- a/objects/oPlayer/Step_0.gml +++ b/objects/oPlayer/Step_0.gml @@ -10,40 +10,52 @@ depth = -bbox_bottom; deplaceHorizontal = keyRight - keyLeft; deplaceVertical = keyDown - keyUp; -if ((deplaceHorizontal > 0 && !place_meeting(x+1, y, oWall)) - || (deplaceHorizontal < 0 && !place_meeting(x-1, y, oWall))) { - x += deplaceHorizontal*spd; -} - -if ((deplaceVertical > 0 && !place_meeting(x, y+1, oWall)) - || (deplaceVertical < 0 && !place_meeting(x, y-1, oWall))) { - y += deplaceVertical*spd; -} - -seDeplace = (deplaceHorizontal != 0 or deplaceVertical != 0); - -// Animation des sprites - -if (seDeplace) { - sprite_index = sPlayerRun; - //image_speed = 1; - if (deplaceHorizontal = 0) { - if (deplaceVertical = 1) { - image_index = compteurFrames % nbFrames; - indexImageInfo = 0; - } else { - image_index = compteurFrames % nbFrames + 2 * nbFrames; - indexImageInfo = 2; - } - } else if (deplaceHorizontal = 1) { - indexImageInfo = 1; - image_index = compteurFrames % nbFrames + nbFrames; - } else { - indexImageInfo = 3; - image_index = compteurFrames % nbFrames + 3*nbFrames; +if (isAttack) { + sprite_index = sPlayerAttackSlash; + image_speed = 1; + if (compteurFrames == 0) { + image_index = indexImageInfo * 4; + } else if (compteurFrames > 4) { + isAttack = false; } - compteurFrames += 0.25*spd; + compteurFrames += 0.25; } else { - sprite_index = sPlayer; - image_index = indexImageInfo; + + if ((deplaceHorizontal > 0 && !place_meeting(x+1, y, oWall)) + || (deplaceHorizontal < 0 && !place_meeting(x-1, y, oWall))) { + x += deplaceHorizontal*spd; + } + + if ((deplaceVertical > 0 && !place_meeting(x, y+1, oWall)) + || (deplaceVertical < 0 && !place_meeting(x, y-1, oWall))) { + y += deplaceVertical*spd; + } + + seDeplace = (deplaceHorizontal != 0 or deplaceVertical != 0); + + // Animation des sprites + + if (seDeplace) { + sprite_index = sPlayerRun; + //image_speed = 1; + if (deplaceHorizontal = 0) { + if (deplaceVertical = 1) { + image_index = compteurFrames % nbFrames; + indexImageInfo = 0; + } else { + image_index = compteurFrames % nbFrames + 2 * nbFrames; + indexImageInfo = 2; + } + } else if (deplaceHorizontal = 1) { + indexImageInfo = 1; + image_index = compteurFrames % nbFrames + nbFrames; + } else { + indexImageInfo = 3; + image_index = compteurFrames % nbFrames + 3*nbFrames; + } + compteurFrames += 0.25*spd; + } else { + sprite_index = sPlayer; + image_index = indexImageInfo; + } } \ No newline at end of file