S
Sudo_Radish
Guest
Hi all.
I am currently in the middle of making a C64 style retro platformer. I have been following Shaun's tutorials and I have included the code to detect inclines. I intend to use this for stairs in the game. However I am finding that when the player character drops from a ledge there is a split second where the player can correct and return back onto the ledge. Also when the player jumps up to a ledge the character is almost launched a bit further.
I will include the code that I have got in my character object.
My question is simple really. Is there a way of making it so that once the character drop from a ledge they cannot correct and fall? Or is this a limitation within GM:S that I am going to have to work with?
I am currently in the middle of making a C64 style retro platformer. I have been following Shaun's tutorials and I have included the code to detect inclines. I intend to use this for stairs in the game. However I am finding that when the player character drops from a ledge there is a split second where the player can correct and return back onto the ledge. Also when the player jumps up to a ledge the character is almost launched a bit further.
I will include the code that I have got in my character object.
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_platform))
{
vsp = key_jump * -jumpspeed
}
//Horizontal Collision
if (place_meeting(x+hsp,y,obj_platform))
{
//Stairs detection
yplus = 0;
while (place_meeting(x+hsp,y-yplus,obj_platform) && yplus <= abs (4*hsp)) yplus += 1;
if place_meeting(x+hsp,y-yplus,obj_platform)
{
//Standard collision detection
while(!place_meeting(x+sign(hsp),y,obj_platform))
x += sign(hsp);
hsp = 0;
}
else
{
y -= yplus;
}
}
x += hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,obj_platform))
{
while(!place_meeting(x,y+sign(vsp),obj_platform))
{
y += sign(vsp);
}
vsp = 0;
}
y += vsp;