2020-12-06 22:05:18 +00:00
|
|
|
keyLeft = keyboard_check(vk_left) or keyboard_check(ord("Q")) or keyboard_check(ord("A"));
|
2020-12-05 15:09:52 +00:00
|
|
|
keyRight = keyboard_check(vk_right) or keyboard_check(ord("D"));
|
2020-12-06 22:05:18 +00:00
|
|
|
keyUp = keyboard_check(vk_up) or keyboard_check(ord("Z")) or keyboard_check(ord("W"));
|
2020-12-05 15:09:52 +00:00
|
|
|
keyDown = keyboard_check(vk_down) or keyboard_check(ord("S"));
|
|
|
|
|
|
|
|
|
|
|
|
// Déplacement du joueur
|
2020-12-06 11:57:05 +00:00
|
|
|
depth = -bbox_bottom;
|
2020-12-05 15:09:52 +00:00
|
|
|
|
|
|
|
deplaceHorizontal = keyRight - keyLeft;
|
|
|
|
deplaceVertical = keyDown - keyUp;
|
|
|
|
|
2020-12-06 13:31:54 +00:00
|
|
|
if (isAttack) {
|
|
|
|
sprite_index = sPlayerAttackSlash;
|
2020-12-06 18:49:25 +00:00
|
|
|
image_speed = 1.5;
|
2020-12-06 13:31:54 +00:00
|
|
|
if (compteurFrames == 0) {
|
|
|
|
image_index = indexImageInfo * 4;
|
|
|
|
} else if (compteurFrames > 4) {
|
|
|
|
isAttack = false;
|
|
|
|
}
|
2020-12-06 18:49:25 +00:00
|
|
|
compteurFrames += 0.5;
|
2020-12-06 13:31:54 +00:00
|
|
|
} else {
|
|
|
|
|
2020-12-06 18:43:41 +00:00
|
|
|
if ((deplaceHorizontal > 0 && !place_meeting(x+2, y, oWall))
|
|
|
|
|| (deplaceHorizontal < 0 && !place_meeting(x-2, y, oWall))) {
|
2020-12-06 13:31:54 +00:00
|
|
|
x += deplaceHorizontal*spd;
|
|
|
|
}
|
|
|
|
|
2020-12-06 18:43:41 +00:00
|
|
|
if ((deplaceVertical > 0 && !place_meeting(x, y+2, oWall))
|
|
|
|
|| (deplaceVertical < 0 && !place_meeting(x, y-2, oWall))) {
|
2020-12-06 13:31:54 +00:00
|
|
|
y += deplaceVertical*spd;
|
|
|
|
}
|
|
|
|
|
|
|
|
seDeplace = (deplaceHorizontal != 0 or deplaceVertical != 0);
|
|
|
|
|
|
|
|
// Animation des sprites
|
|
|
|
|
|
|
|
if (seDeplace) {
|
|
|
|
sprite_index = sPlayerRun;
|
|
|
|
//image_speed = 1;
|
|
|
|
if (deplaceHorizontal = 0) {
|
|
|
|
if (deplaceVertical = 1) {
|
|
|
|
image_index = compteurFrames % nbFrames;
|
|
|
|
indexImageInfo = 0;
|
|
|
|
} else {
|
|
|
|
image_index = compteurFrames % nbFrames + 2 * nbFrames;
|
|
|
|
indexImageInfo = 2;
|
|
|
|
}
|
|
|
|
} else if (deplaceHorizontal = 1) {
|
|
|
|
indexImageInfo = 1;
|
|
|
|
image_index = compteurFrames % nbFrames + nbFrames;
|
2020-12-05 21:26:40 +00:00
|
|
|
} else {
|
2020-12-06 13:31:54 +00:00
|
|
|
indexImageInfo = 3;
|
|
|
|
image_index = compteurFrames % nbFrames + 3*nbFrames;
|
2020-12-05 21:26:40 +00:00
|
|
|
}
|
2020-12-06 13:31:54 +00:00
|
|
|
compteurFrames += 0.25*spd;
|
2020-12-05 21:26:40 +00:00
|
|
|
} else {
|
2020-12-06 13:31:54 +00:00
|
|
|
sprite_index = sPlayer;
|
|
|
|
image_index = indexImageInfo;
|
2020-12-05 21:26:40 +00:00
|
|
|
}
|
2020-12-05 13:48:00 +00:00
|
|
|
}
|