ajout fonction check rectangle et détection d'un ennemi lors de l'attaque
This commit is contained in:
parent
e672b38824
commit
148ea2197b
3 changed files with 39 additions and 6 deletions
|
@ -7,24 +7,40 @@
|
||||||
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, true, oPlayer);
|
||||||
|
//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, true, oPlayer);
|
||||||
|
//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, true, oPlayer);
|
||||||
|
//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, true, oPlayer);
|
||||||
|
//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
|
||||||
} else {
|
} else {
|
||||||
//a supp
|
//a supp
|
||||||
show_debug_message("pas d'objet...");
|
show_debug_message("pas d'objet...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (inst != noone && !ds_list_empty(inst)) {
|
||||||
|
show_debug_message("objet trouvé !");
|
||||||
|
show_debug_message(inst);
|
||||||
|
with (inst) instance_destroy();
|
||||||
|
// attaque
|
||||||
|
} else {
|
||||||
|
//a supp
|
||||||
|
show_debug_message("pas d'objet...");
|
||||||
|
}
|
||||||
|
*/
|
|
@ -24,6 +24,7 @@
|
||||||
{"isDnD":false,"eventNum":0,"eventType":3,"collisionObjectId":null,"parent":{"name":"oPlayer","path":"objects/oPlayer/oPlayer.yy",},"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",},
|
{"isDnD":false,"eventNum":0,"eventType":3,"collisionObjectId":null,"parent":{"name":"oPlayer","path":"objects/oPlayer/oPlayer.yy",},"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",},
|
||||||
{"isDnD":false,"eventNum":0,"eventType":0,"collisionObjectId":null,"parent":{"name":"oPlayer","path":"objects/oPlayer/oPlayer.yy",},"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",},
|
{"isDnD":false,"eventNum":0,"eventType":0,"collisionObjectId":null,"parent":{"name":"oPlayer","path":"objects/oPlayer/oPlayer.yy",},"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",},
|
||||||
{"isDnD":false,"eventNum":74,"eventType":9,"collisionObjectId":null,"parent":{"name":"oPlayer","path":"objects/oPlayer/oPlayer.yy",},"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",},
|
{"isDnD":false,"eventNum":74,"eventType":9,"collisionObjectId":null,"parent":{"name":"oPlayer","path":"objects/oPlayer/oPlayer.yy",},"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",},
|
||||||
|
{"isDnD":false,"eventNum":0,"eventType":4,"collisionObjectId":{"name":"oMonster","path":"objects/oMonster/oMonster.yy",},"parent":{"name":"oPlayer","path":"objects/oPlayer/oPlayer.yy",},"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",},
|
||||||
],
|
],
|
||||||
"properties": [
|
"properties": [
|
||||||
{"varType":1,"value":"0","rangeEnabled":false,"rangeMin":0.0,"rangeMax":10.0,"listItems":[],"multiselect":false,"filters":[],"resourceVersion":"1.0","name":"deplaceHorizontal","tags":[],"resourceType":"GMObjectProperty",},
|
{"varType":1,"value":"0","rangeEnabled":false,"rangeMin":0.0,"rangeMax":10.0,"listItems":[],"multiselect":false,"filters":[],"resourceVersion":"1.0","name":"deplaceHorizontal","tags":[],"resourceType":"GMObjectProperty",},
|
||||||
|
|
|
@ -1,7 +1,23 @@
|
||||||
// Script assets have changed for v2.3.0 see
|
// Script assets have changed for v2.3.0 see
|
||||||
// https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information
|
// https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information
|
||||||
|
|
||||||
function Test(){
|
/*
|
||||||
// C'est un test de git
|
@description Récupère tous les instances d'obj se trouvant dans un rectangle
|
||||||
//retest git
|
@param {x1} coordonnée x gauche du rectangle
|
||||||
|
@param {y1} coordonnée y haut du rectangle
|
||||||
|
@param {x2} coordonnée x droit du rectangle
|
||||||
|
@param {y2} coordonnée y bas du rectangle
|
||||||
|
@param {obj} le type des instances à chercher
|
||||||
|
@return la liste des id des instances se trouvant dans le restangle
|
||||||
|
*/
|
||||||
|
function getCollisionArea(x1, y1, x2, y2, obj){
|
||||||
|
list = ds_list_create();
|
||||||
|
|
||||||
|
with(obj) {
|
||||||
|
if ( x >= x1 && x <= x2 && y >= y1 && y <= y2) {
|
||||||
|
ds_list_add(list, obj.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
}
|
}
|
Reference in a new issue