I just restarted working with GMS2 and came across my first problem pretty fast :/
Below is my code for the player movement.
I want my object/player to move left, right and jump.
It works so far, but I am unable to code it the way that the player can jump
diagonal while keep pressing VK_LEFT (or right) and then hitting VK_UP once...
Below is my code for the player movement.
I want my object/player to move left, right and jump.
It works so far, but I am unable to code it the way that the player can jump
diagonal while keep pressing VK_LEFT (or right) and then hitting VK_UP once...
GML:
if !place_meeting(x,y+1,obj_baseground)
{
gravity = 2.5;
grounded = 0;
}else
{
gravity = 0;
grounded = 1;
}
if keyboard_check(vk_right) //move right
{
speed=5; image_speed=3;
if(grounded == 1)
{
sprite_index =Vik1Run;
}
direction=0;
}else if keyboard_check(vk_left) //move left
{
speed=5;
image_speed=3;
if(grounded == 1)
{
sprite_index =Vik1Run;
}
direction=180;
}else if (keyboard_check(vk_up) && grounded == 1) //jump only when grounded
{
grounded =0;
sprite_index = Vik1Jump; speed=255; image_speed=3; direction=90; // direction should have done the trick??
}
else { sprite_index =Vik1Stand; speed=0; image_speed = 3;}