btw sorry english is not my mother language
so im trying to program a wall jump mechanic and it works... well kinda
when i wall jump im trying to make the player jump to the opposite direction
i illustrated what im talking about here
so im trying to program a wall jump mechanic and it works... well kinda
when i wall jump im trying to make the player jump to the opposite direction
i illustrated what im talking about here
GML:
///input
lkey = -(keyboard_check(ord("A")));
rkey = (keyboard_check(ord("D")));
ukey = (keyboard_check_pressed(vk_space));
move = lkey + rkey;
hspd = move * movespd;
///ground check
grounded = place_meeting(x,y+1, objsolid);
if (vsp < maxgrav) vsp += grav;
if grounded jumps = global.maxjumps;
if ukey && jumps > 0
{
jumps -= 1;
vsp = -jumpspd
}
///horizontal collision
if (place_meeting(x+hspd, y, objsolid)){
while (!place_meeting(x+sign(hspd),y,objsolid)){
x += sign(hspd);
}
clingable = true
hspd = 0;
} else clingable = false
x += hspd;
///vertical collision
if (place_meeting(x, y+vsp, objsolid)) {
while (!place_meeting(x,y+sign(vsp),objsolid)) {
y += sign(vsp);
}
vsp = 0;
}
y += vsp;
///cosmetic fixes
if move != 0
image_xscale = move;
if keyboard_check(vk_escape) game_end()
///interaction with other objects
if place_meeting(x,y,Gravity1)
{
vsp =- 1;
jumps = global.maxjumps;
}
///wall clings
if grounded = false and clingable = true
{
clinged = true
grav = 0.2
} else
{
grav = 0.4
clinged = false
}
///wall jump
if ukey and clinged = true
{
jumps -= 1;
vsp = -jumpspd
}