M
Midastouch
Guest
Hello everyone, i need some help for my little project
I try to put a dash animation, when i click on the space key i want my player doing a little dash forward.
My problem is that the sprite change only when the key space is pressed.
And this dash look more than a teleport than a dash.
I try to put a dash animation, when i click on the space key i want my player doing a little dash forward.
My problem is that the sprite change only when the key space is pressed.
And this dash look more than a teleport than a dash.
Code:
var input_horizontal = keyboard_check(key_right) - keyboard_check(key_left);
var input_vertical = keyboard_check(key_down);
var input_jump = keyboard_check_pressed(key_jump);
var input_down = keyboard_check_pressed(key_down);
if input_horizontal = 1 {image_xscale = -1}
if input_horizontal = -1 {image_xscale = 1}
if input_horizontal = 0 {state = "idle"}
if input_horizontal != 0 {state = "move"}
if keyboard_check_pressed(vk_space){state = "dash"}
if state == "idle" {sprite_index = spr_Player_idle;}
if state == "move" {sprite_index = spr_Player_move;
max_horizontal_speed = 8;}
if state == "dash"
{max_horizontal_speed = 2
sprite_index = spr_player_dash;
image_speed = 0.5;
if image_xscale == 1 and not place_meeting (x-40,y,obj_Wall)
{
x-=40;
}
if image_xscale == -1 and not place_meeting (x+40,y,obj_Wall)
{
x+=40;
}
}
else {state = "move"}