A
AtomicToilet
Guest
Hola!
In messing around with a Wall Climb code, I accidentally made it so that the Player can actually stick to a wall in the place they touch it - which is actually a pretty cool thing, so I want to keep it.
ie. When the Player jumps (or is falling) against a wall and presses right and left together, they stick to the wall. Once either key is released, gravity works like normal and the Player drops down.
My problem is, it only works when the Player object is moving/facing left...! Can anyone help me figure out why? Cheers!
Here's all my move code, up to and including the wall cling:
I have a feeling there's some kind of conflict, maybe, with the jump code...? But I'm not sure. Any suggestions greatly appreciated!
In messing around with a Wall Climb code, I accidentally made it so that the Player can actually stick to a wall in the place they touch it - which is actually a pretty cool thing, so I want to keep it.
ie. When the Player jumps (or is falling) against a wall and presses right and left together, they stick to the wall. Once either key is released, gravity works like normal and the Player drops down.
My problem is, it only works when the Player object is moving/facing left...! Can anyone help me figure out why? Cheers!
Here's all my move code, up to and including the wall cling:
Code:
//React to inputs
move = key_left + key_right;
hsp = move * spd;
if (vsp < 10) vsp += grav;
if (place_meeting(x,y+1,obj_wall))
{
on_ground = false;
}
else if (!place_meeting(x,y+2,obj_wall))
{
on_ground = true;
}
//JUMP CODE
if (!place_meeting(x,y+1,obj_wall))
{
vsp += grav;
//Control jump height
if (key_up_released && vsp < -4)
{
vsp = -4;
}
}
else
{
vsp = 0;
if (key_up)
{
audio_play_sound(snd_jump,5,false);
vsp = jumpspeed;
}
}
//Friction
if(!key_right && key_left = 0 && hsp != 0)
{
hsp = ((abs(hsp)- fric) * sign(hsp));
}
else
{
hsp = move * spd;
}
//WALL CLING
if (key_right) && place_meeting(x-2,y, obj_wall) && !place_meeting(x, y+2, obj_wall) && !(key_left)
{
vsp = 0;
sprite_index = spr_player_ledge;
}
if (key_left) && place_meeting(x+2,y, obj_wall) && !place_meeting(x, y+2, obj_wall) && !(key_right)
{
vsp = 0;
sprite_index = spr_player_ledge;
}