4
0
Fork 0

Ajout détection sprite attaque corps à corps

This commit is contained in:
rick 2020-12-05 16:09:52 +01:00
parent bd7a1411f9
commit 2ea0418857
3 changed files with 96 additions and 66 deletions

View file

@ -0,0 +1,30 @@
// Attaque au corp à corp
//jouer l'animation
tailleEpee = 20; // à définir
switch (image_index) {
case 0:
inst = collision_rectangle(x+5, y+tailleEpee, x-5, y+tailleEpee, oMonster, true, oPlayer);
break;
case 1:
inst = collision_rectangle(x+tailleEpee, y+5, x+tailleEpee, y-5, oMonster, true, oPlayer);
break;
case 2:
inst = collision_rectangle(x+5, y-tailleEpee, x-5, y-tailleEpee, oMonster, true, oPlayer);
break;
case 3:
inst = collision_rectangle(x-tailleEpee, y+5, x-tailleEpee, y-5, oMonster, true, oPlayer);
break;
default:
inst = noone;
}
if (inst != noone) {
show_debug_message("objet trouvé !");
// attaque
} else {
//a supp
show_debug_message("pas d'objet...");
}

View file

@ -1,27 +1,26 @@
keyLeft = keyboard_check(vk_left) or keyboard_check(ord("Q"));
keyRight = keyboard_check(vk_right) or keyboard_check(ord("D"));
keyUp = keyboard_check(vk_up) or keyboard_check(ord("Z"));
keyDown = keyboard_check(vk_down) or keyboard_check(ord("S"));
keyAttack = keyboard_check_pressed(vk_shift);
// Déplacement du joueur
deplaceHorizontal = keyRight - keyLeft;
deplaceVertical = keyDown - keyUp;
x += deplaceHorizontal;
y += deplaceVertical;
seDeplace = (deplaceHorizontal != 0 or deplaceVertical != 0);
// Animation des sprites
if (seDeplace) {
if (deplaceHorizontal = 0) {
if (deplaceVertical = 1) image_index = 0;
else image_index = 2;
}
else if (deplaceHorizontal = 1) image_index = 1;
else image_index = 3;
keyLeft = keyboard_check(vk_left) or keyboard_check(ord("Q"));
keyRight = keyboard_check(vk_right) or keyboard_check(ord("D"));
keyUp = keyboard_check(vk_up) or keyboard_check(ord("Z"));
keyDown = keyboard_check(vk_down) or keyboard_check(ord("S"));
// Déplacement du joueur
deplaceHorizontal = keyRight - keyLeft;
deplaceVertical = keyDown - keyUp;
x += deplaceHorizontal;
y += deplaceVertical;
seDeplace = (deplaceHorizontal != 0 or deplaceVertical != 0);
// Animation des sprites
if (seDeplace) {
if (deplaceHorizontal = 0) {
if (deplaceVertical = 1) image_index = 0;
else image_index = 2;
}
else if (deplaceHorizontal = 1) image_index = 1;
else image_index = 3;
}

View file

@ -1,41 +1,42 @@
{
"spriteId": {
"name": "sPlayer",
"path": "sprites/sPlayer/sPlayer.yy",
},
"solid": false,
"visible": true,
"spriteMaskId": null,
"persistent": false,
"parentObjectId": null,
"physicsObject": false,
"physicsSensor": false,
"physicsShape": 1,
"physicsGroup": 1,
"physicsDensity": 0.5,
"physicsRestitution": 0.1,
"physicsLinearDamping": 0.1,
"physicsAngularDamping": 0.1,
"physicsFriction": 0.2,
"physicsStartAwake": true,
"physicsKinematic": false,
"physicsShapePoints": [],
"eventList": [
{"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",},
],
"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":"deplaceVertical","tags":[],"resourceType":"GMObjectProperty",},
{"varType":0,"value":"0","rangeEnabled":false,"rangeMin":0.0,"rangeMax":10.0,"listItems":[],"multiselect":false,"filters":[],"resourceVersion":"1.0","name":"spriteDir","tags":[],"resourceType":"GMObjectProperty",},
],
"overriddenProperties": [],
"parent": {
"name": "Entity",
"path": "folders/Objects/Entity.yy",
},
"resourceVersion": "1.0",
"name": "oPlayer",
"tags": [],
"resourceType": "GMObject",
{
"spriteId": {
"name": "sPlayer",
"path": "sprites/sPlayer/sPlayer.yy",
},
"solid": false,
"visible": true,
"spriteMaskId": null,
"persistent": false,
"parentObjectId": null,
"physicsObject": false,
"physicsSensor": false,
"physicsShape": 1,
"physicsGroup": 1,
"physicsDensity": 0.5,
"physicsRestitution": 0.1,
"physicsLinearDamping": 0.1,
"physicsAngularDamping": 0.1,
"physicsFriction": 0.2,
"physicsStartAwake": true,
"physicsKinematic": false,
"physicsShapePoints": [],
"eventList": [
{"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":74,"eventType":9,"collisionObjectId":null,"parent":{"name":"oPlayer","path":"objects/oPlayer/oPlayer.yy",},"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",},
],
"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":"deplaceVertical","tags":[],"resourceType":"GMObjectProperty",},
{"varType":0,"value":"0","rangeEnabled":false,"rangeMin":0.0,"rangeMax":10.0,"listItems":[],"multiselect":false,"filters":[],"resourceVersion":"1.0","name":"spriteDir","tags":[],"resourceType":"GMObjectProperty",},
],
"overriddenProperties": [],
"parent": {
"name": "Entity",
"path": "folders/Objects/Entity.yy",
},
"resourceVersion": "1.0",
"name": "oPlayer",
"tags": [],
"resourceType": "GMObject",
}