4
0
Fork 0

Ajout code animation lors attaque joueur

This commit is contained in:
rick 2020-12-06 14:31:54 +01:00
parent d6c4b3411c
commit 3c8e8dfd6a
3 changed files with 53 additions and 39 deletions

View file

@ -6,3 +6,4 @@ indexImageInfo = 0;
compteurFrames = 0; compteurFrames = 0;
attack = 10; attack = 10;
isAttack = false; // permet de savoir si le joueur a appuyé sur la touche attaquer ou pas

View file

@ -1,10 +1,11 @@
// Attaque au corp à corp // Attaque au corp à corp
//jouer l'animation //jouer l'animation
isAttack = true;
tailleEpee = 30; // à définir compteurFrames = 0;
checkCote = image_index / 8; // récupère où regarde le personnage tailleEpee = 30; // à définir
inst = noone; checkCote = image_index / 8; // récupère où regarde le personnage
inst = noone;
if (sprite_index == sPlayerRun) { if (sprite_index == sPlayerRun) {
if (checkCote <= 1) { if (checkCote <= 1) {

View file

@ -10,21 +10,32 @@ depth = -bbox_bottom;
deplaceHorizontal = keyRight - keyLeft; deplaceHorizontal = keyRight - keyLeft;
deplaceVertical = keyDown - keyUp; deplaceVertical = keyDown - keyUp;
if ((deplaceHorizontal > 0 && !place_meeting(x+1, y, oWall)) if (isAttack) {
sprite_index = sPlayerAttackSlash;
image_speed = 1;
if (compteurFrames == 0) {
image_index = indexImageInfo * 4;
} else if (compteurFrames > 4) {
isAttack = false;
}
compteurFrames += 0.25;
} else {
if ((deplaceHorizontal > 0 && !place_meeting(x+1, y, oWall))
|| (deplaceHorizontal < 0 && !place_meeting(x-1, y, oWall))) { || (deplaceHorizontal < 0 && !place_meeting(x-1, y, oWall))) {
x += deplaceHorizontal*spd; x += deplaceHorizontal*spd;
} }
if ((deplaceVertical > 0 && !place_meeting(x, y+1, oWall)) if ((deplaceVertical > 0 && !place_meeting(x, y+1, oWall))
|| (deplaceVertical < 0 && !place_meeting(x, y-1, oWall))) { || (deplaceVertical < 0 && !place_meeting(x, y-1, oWall))) {
y += deplaceVertical*spd; y += deplaceVertical*spd;
} }
seDeplace = (deplaceHorizontal != 0 or deplaceVertical != 0); seDeplace = (deplaceHorizontal != 0 or deplaceVertical != 0);
// Animation des sprites // Animation des sprites
if (seDeplace) { if (seDeplace) {
sprite_index = sPlayerRun; sprite_index = sPlayerRun;
//image_speed = 1; //image_speed = 1;
if (deplaceHorizontal = 0) { if (deplaceHorizontal = 0) {
@ -43,7 +54,8 @@ if (seDeplace) {
image_index = compteurFrames % nbFrames + 3*nbFrames; image_index = compteurFrames % nbFrames + 3*nbFrames;
} }
compteurFrames += 0.25*spd; compteurFrames += 0.25*spd;
} else { } else {
sprite_index = sPlayer; sprite_index = sPlayer;
image_index = indexImageInfo; image_index = indexImageInfo;
}
} }