P
PantsOfAwesome
Guest
I've started making a platformer but my double jump system does not work for some reason, I was wondering if you could help me fix it (please).
Here is my create code:
And here is my step code:
Thanks in advance to anyone who tries to help!
Here is my create code:
Code:
grav = 0.2;
hsp = 0;
vsp = 0;
jumpspeed = 7;
movespeed = 4;
cur_jumps = 0;
Code:
//Recieve Input
key_left = -keyboard_check(vk_left);
key_right = keyboard_check(vk_right);
key_jump = keyboard_check(vk_space);
key_run = keyboard_check(vk_shift);
//Use inputs
move = (key_left + key_right);
hsp = move * movespeed;
if(key_run)
hsp = move * 2 * movespeed;
if(vsp < 10) vsp+=grav;
if(place_meeting(x,y+1,obj_wall))
{
cur_jumps = 0;
}
if(cur_jumps < 2) && (key_jump)
{
cur_jumps += 1;
vsp = -jumpspeed;
}
//Horizontal Collision
if(place_meeting(x+hsp,y,obj_wall))
{
while(!place_meeting(x+sign(hsp),y,obj_wall))
x+=sign(hsp);
hsp=0;
}
//Vertical Collision
if(place_meeting(x,y+vsp,obj_wall))
{
while(!place_meeting(x,y+sign(vsp),obj_wall))
y+=sign(vsp);
vsp=0;
}
x+=hsp;
y+=vsp;