F
filipe
Guest
I have just finished following this plat-former tutorial the code works great but i more than one wall
i have try to use the parents thing but the other walls will fall down because of the player code.
here is the tutorial
and the all the code related to that tutorial
i have try to use the parents thing but the other walls will fall down because of the player code.
here is the tutorial
Code:
///Initialize Variable
grav = 0.2;
hsp = 0;
vsp = 0;
jumpspeed = 7;
movespeed = 4;
Code:
///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_ground))
{
vsp = key_jump * -jumpspeed
}
//Horizontal Collision
if (place_meeting(x+hsp,y,obj_ground))
{
while(!place_meeting(x+sign(hsp),y,obj_ground))
{
x += sign(hsp);
}
hsp = 0;
}
x += hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,obj_ground))
{
while(!place_meeting(x,y+sign(vsp),obj_ground))
{
x += sign(vsp);
}
vsp = 0;
}
y += vsp;