Ajout recul sur monstre lors attaque joueur
This commit is contained in:
parent
441845b52d
commit
f8f5f7952a
6 changed files with 83 additions and 55 deletions
|
@ -8,6 +8,7 @@ dir = 3;
|
|||
pv = 5;
|
||||
|
||||
attack = 1;
|
||||
touche = 0; // s'ils sont touchés
|
||||
|
||||
enum typeMelee {
|
||||
squelette,
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
// deplacement monstre
|
||||
|
||||
if dureeDeplacement != 0 {
|
||||
if (touche == 0) {
|
||||
if dureeDeplacement != 0 {
|
||||
x += deplaceHorizontal;
|
||||
y += deplaceVertical;
|
||||
dureeDeplacement --;
|
||||
}
|
||||
else {
|
||||
}
|
||||
else {
|
||||
deplaceHorizontal = 0;
|
||||
deplaceVertical = 0;
|
||||
dir = irandom(3);
|
||||
switch(dir) {
|
||||
switch(dir) {
|
||||
case 0 : deplaceVertical = 1; break;
|
||||
case 1 : deplaceHorizontal = 1; break;
|
||||
case 2 : deplaceVertical = -1; break;
|
||||
|
@ -17,11 +18,11 @@ switch(dir) {
|
|||
}
|
||||
|
||||
dureeDeplacement = 120;
|
||||
}
|
||||
}
|
||||
|
||||
// collision avec un mur
|
||||
// collision avec un mur
|
||||
|
||||
if place_meeting(x,y,oWall) {
|
||||
if place_meeting(x,y,oWall) {
|
||||
if (dir > 1) dir -= 2;
|
||||
else dir += 2;
|
||||
|
||||
|
@ -33,4 +34,7 @@ if place_meeting(x,y,oWall) {
|
|||
}
|
||||
|
||||
dureeDeplacement = 120;
|
||||
}
|
||||
} else {
|
||||
touche--;
|
||||
}
|
|
@ -7,6 +7,7 @@ image_speed = 1;
|
|||
switch (monType) {
|
||||
case typeMelee.squelette:
|
||||
attack = 10;
|
||||
pv = 20;
|
||||
sprite_index = sSkeletonR;
|
||||
break;
|
||||
case typeMelee.blob:
|
||||
|
|
|
@ -4,3 +4,5 @@ inv = 0; //timer invinsiblité
|
|||
|
||||
indexImageInfo = 0;
|
||||
compteurFrames = 0;
|
||||
|
||||
attack = 10;
|
|
@ -2,32 +2,52 @@
|
|||
|
||||
//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) {
|
||||
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);
|
||||
break;
|
||||
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)
|
||||
break;
|
||||
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)
|
||||
break;
|
||||
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);
|
||||
break;
|
||||
default:
|
||||
inst = noone;
|
||||
}
|
||||
}
|
||||
|
||||
if (inst != noone) {
|
||||
show_debug_message("objet trouvé !");
|
||||
// attaque
|
||||
hit(self, inst, attack);
|
||||
inst.touche = 30;
|
||||
} else {
|
||||
//a supp
|
||||
show_debug_message("pas d'objet...");
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
@param {objRepousse} objet qui sera repoussé
|
||||
*/
|
||||
function knockBack(obj, objRepousse) {
|
||||
knockback = 10;
|
||||
knockback = 20;
|
||||
oY = objRepousse.y;
|
||||
oX = objRepousse.x;
|
||||
if (obj.x > oX && !place_meeting(oX-knockback-1, oY, oWall)) {
|
||||
|
|
Reference in a new issue