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,5 +1,6 @@
// deplacement monstre // deplacement monstre
if (touche == 0) {
if dureeDeplacement != 0 { if dureeDeplacement != 0 {
x += deplaceHorizontal; x += deplaceHorizontal;
y += deplaceVertical; y += deplaceVertical;
@ -34,3 +35,6 @@ if place_meeting(x,y,oWall) {
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

@ -4,3 +4,5 @@ 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;
if (sprite_index == sPlayerRun) {
if (checkCote <= 1) {
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);
} else if (checkCote <= 2) {
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)
} else if (checkCote <= 3) {
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)
} else if (checkCote <= 4) {
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);
}
} else {
switch (image_index) { switch (image_index) {
case 0: case 0:
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; break;
case 1: case 1:
inst = collision_rectangle(x+tailleEpee, y+5, x+tailleEpee, y-5, oMonster, true, oPlayer); 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) //inst = getCollisionArea(x+tailleEpee, y+5, x+tailleEpee, y-5, oMonster)
break; break;
case 2: case 2:
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; break;
case 3: case 3:
inst = collision_rectangle(x-tailleEpee, y+5, x-tailleEpee, y-5, oMonster, true, oPlayer); 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); //inst = getCollisionArea(x-tailleEpee, y+5, x-tailleEpee, y-5, oMonster);
break; break;
default: default:
inst = noone; 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)) {