4
0
Fork 0

Ajout recul sur monstre lors attaque joueur

This commit is contained in:
rick 2020-12-06 12:38:35 +01:00
parent 441845b52d
commit f8f5f7952a
6 changed files with 83 additions and 55 deletions

View file

@ -8,6 +8,7 @@ dir = 3;
pv = 5; pv = 5;
attack = 1; attack = 1;
touche = 0; // s'ils sont touchés
enum typeMelee { enum typeMelee {
squelette, squelette,

View file

@ -1,36 +1,40 @@
// deplacement monstre // deplacement monstre
if dureeDeplacement != 0 { if (touche == 0) {
x += deplaceHorizontal; if dureeDeplacement != 0 {
y += deplaceVertical; x += deplaceHorizontal;
dureeDeplacement --; y += deplaceVertical;
} dureeDeplacement --;
else { }
deplaceHorizontal = 0; else {
deplaceVertical = 0; deplaceHorizontal = 0;
dir = irandom(3); deplaceVertical = 0;
switch(dir) { dir = irandom(3);
case 0 : deplaceVertical = 1; break; switch(dir) {
case 1 : deplaceHorizontal = 1; break; case 0 : deplaceVertical = 1; break;
case 2 : deplaceVertical = -1; break; case 1 : deplaceHorizontal = 1; break;
case 3 : deplaceHorizontal = -1; break; case 2 : deplaceVertical = -1; break;
} case 3 : deplaceHorizontal = -1; break;
}
dureeDeplacement = 120;
} dureeDeplacement = 120;
}
// collision avec un mur
// collision avec un mur
if place_meeting(x,y,oWall) {
if (dir > 1) dir -= 2; if place_meeting(x,y,oWall) {
else dir += 2; if (dir > 1) dir -= 2;
else dir += 2;
switch(dir) {
case 0 : deplaceVertical = 1; break; switch(dir) {
case 1 : deplaceHorizontal = 1; break; case 0 : deplaceVertical = 1; break;
case 2 : deplaceVertical = -1; break; case 1 : deplaceHorizontal = 1; break;
case 3 : deplaceHorizontal = -1; break; case 2 : deplaceVertical = -1; break;
} case 3 : deplaceHorizontal = -1; break;
}
dureeDeplacement = 120;
} dureeDeplacement = 120;
}
} else {
touche--;
}

View file

@ -7,6 +7,7 @@ image_speed = 1;
switch (monType) { switch (monType) {
case typeMelee.squelette: case typeMelee.squelette:
attack = 10; attack = 10;
pv = 20;
sprite_index = sSkeletonR; sprite_index = sSkeletonR;
break; break;
case typeMelee.blob: case typeMelee.blob:

View file

@ -3,4 +3,6 @@ pv = 100;
inv = 0; //timer invinsiblité inv = 0; //timer invinsiblité
indexImageInfo = 0; indexImageInfo = 0;
compteurFrames = 0; compteurFrames = 0;
attack = 10;

View file

@ -2,32 +2,52 @@
//jouer l'animation //jouer l'animation
tailleEpee = 20; // à définir tailleEpee = 30; // à définir
checkCote = image_index / 8; // récupère où regarde le personnage
inst = noone;
switch (image_index) { if (sprite_index == sPlayerRun) {
case 0: if (checkCote <= 1) {
inst = collision_rectangle(x+5, y+tailleEpee, x-5, y+tailleEpee, oMonster, true, oPlayer); inst = collision_rectangle(x+5, y+tailleEpee, x-5, y+tailleEpee, oMonster, false, oPlayer);
//inst = getCollisionArea(x-5, y+tailleEpee, x+5, y+tailleEpee, oMonster); //inst = getCollisionArea(x-5, y+tailleEpee, x+5, y+tailleEpee, oMonster);
break; } else if (checkCote <= 2) {
case 1: inst = collision_rectangle(x+tailleEpee, y+5, x+tailleEpee, y-5, oMonster, false, oPlayer);
inst = collision_rectangle(x+tailleEpee, y+5, x+tailleEpee, y-5, oMonster, true, oPlayer);
//inst = getCollisionArea(x+tailleEpee, y+5, x+tailleEpee, y-5, oMonster) //inst = getCollisionArea(x+tailleEpee, y+5, x+tailleEpee, y-5, oMonster)
break; } else if (checkCote <= 3) {
case 2: inst = collision_rectangle(x+5, y-tailleEpee, x-5, y-tailleEpee, oMonster, false, oPlayer);
inst = collision_rectangle(x+5, y-tailleEpee, x-5, y-tailleEpee, oMonster, true, oPlayer);
//inst = getCollisionArea(x+5, y-tailleEpee, x-5, y-tailleEpee, oMonster) //inst = getCollisionArea(x+5, y-tailleEpee, x-5, y-tailleEpee, oMonster)
break; } else if (checkCote <= 4) {
case 3: inst = collision_rectangle(x-tailleEpee, y+5, x-tailleEpee, y-5, oMonster, false, oPlayer);
inst = collision_rectangle(x-tailleEpee, y+5, x-tailleEpee, y-5, oMonster, true, oPlayer);
//inst = getCollisionArea(x-tailleEpee, y+5, x-tailleEpee, y-5, oMonster); //inst = getCollisionArea(x-tailleEpee, y+5, x-tailleEpee, y-5, oMonster);
break; }
default: } else {
inst = noone; switch (image_index) {
} case 0:
inst = collision_rectangle(x+5, y+tailleEpee, x-5, y+tailleEpee, oMonster, false, oPlayer);
//inst = getCollisionArea(x-5, y+tailleEpee, x+5, y+tailleEpee, oMonster);
break;
case 1:
inst = collision_rectangle(x+tailleEpee, y+5, x+tailleEpee, y-5, oMonster, false, oPlayer);
//inst = getCollisionArea(x+tailleEpee, y+5, x+tailleEpee, y-5, oMonster)
break;
case 2:
inst = collision_rectangle(x+5, y-tailleEpee, x-5, y-tailleEpee, oMonster, false, oPlayer);
//inst = getCollisionArea(x+5, y-tailleEpee, x-5, y-tailleEpee, oMonster)
break;
case 3:
inst = collision_rectangle(x-tailleEpee, y+5, x-tailleEpee, y-5, oMonster, false, oPlayer);
//inst = getCollisionArea(x-tailleEpee, y+5, x-tailleEpee, y-5, oMonster);
break;
default:
inst = noone;
}
}
if (inst != noone) { if (inst != noone) {
show_debug_message("objet trouvé !"); show_debug_message("objet trouvé !");
// attaque // attaque
hit(self, inst, attack);
inst.touche = 30;
} else { } else {
//a supp //a supp
show_debug_message("pas d'objet..."); show_debug_message("pas d'objet...");

View file

@ -7,7 +7,7 @@
@param {objRepousse} objet qui sera repoussé @param {objRepousse} objet qui sera repoussé
*/ */
function knockBack(obj, objRepousse) { function knockBack(obj, objRepousse) {
knockback = 10; knockback = 20;
oY = objRepousse.y; oY = objRepousse.y;
oX = objRepousse.x; oX = objRepousse.x;
if (obj.x > oX && !place_meeting(oX-knockback-1, oY, oWall)) { if (obj.x > oX && !place_meeting(oX-knockback-1, oY, oWall)) {