E
ejoshuat
Guest
I can't find anything to actually help me, I have all the movement sorted out and that but Icant find any code in which will change the player or sprite in the facing direction, so when I move left and right it will face the same direction. HELP
This is the code for the step event so far its all in working order:
//Get the player's input
key_right = keyboard_check(vk_right);
key_left = -keyboard_check(vk_left);
key_jump = keyboard_check_pressed(vk_space);
//React to inputs
move = key_left + key_right;
hsp = move * movespeed;
if (vsp < 10) vsp += grav;
if (place_meeting(x,y+1,obj_FloorCENT))
{
vsp = key_jump * -jumpspeed
}
//Horizontal Collision
if (place_meeting(x+hsp,y,obj_FloorCENT))
{
while(!place_meeting(x+sign(hsp),y,obj_FloorCENT))
{
x += sign(hsp);
}
hsp = 0;
}
x += hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,obj_FloorCENT))
{
while(!place_meeting(x,y+sign(vsp),obj_FloorCENT))
{
y += sign(vsp);
}
vsp = 0;
}
y += vsp;
This is the code for the step event so far its all in working order:
//Get the player's input
key_right = keyboard_check(vk_right);
key_left = -keyboard_check(vk_left);
key_jump = keyboard_check_pressed(vk_space);
//React to inputs
move = key_left + key_right;
hsp = move * movespeed;
if (vsp < 10) vsp += grav;
if (place_meeting(x,y+1,obj_FloorCENT))
{
vsp = key_jump * -jumpspeed
}
//Horizontal Collision
if (place_meeting(x+hsp,y,obj_FloorCENT))
{
while(!place_meeting(x+sign(hsp),y,obj_FloorCENT))
{
x += sign(hsp);
}
hsp = 0;
}
x += hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,obj_FloorCENT))
{
while(!place_meeting(x,y+sign(vsp),obj_FloorCENT))
{
y += sign(vsp);
}
vsp = 0;
}
y += vsp;