A
Aaron Walton
Guest
I'm working on a platformer. I've got an issue where, when the player is running towards the edge of a surface, if I try to jump right off the edge, sometimes the player doesn't jump and instead just runs off the edge. I now realize that the issue isn't the jumping itself, but that there *seems* to a latency between the button press and the game registering the button press. I checked this by having the game create an object with the player sprite whenever I press the jump button. So, often when I'm running along a platform and jump near the end, the game only registers the button press after I've fallen off the platform.
Is this my imagination? Am I really just not pressing the jump button as soon as I think I am? Or is there some kind of latency issue that I'm not accounting for? I'm still a super beginner, and this is pretty much just Shaun Spaulding's platformer tutorial code. Just want to figure out if I'm crazy or if there's a way to work around this, or what.
EDIT: Sorry, of course I should have included code!
Is this my imagination? Am I really just not pressing the jump button as soon as I think I am? Or is there some kind of latency issue that I'm not accounting for? I'm still a super beginner, and this is pretty much just Shaun Spaulding's platformer tutorial code. Just want to figure out if I'm crazy or if there's a way to work around this, or what.
EDIT: Sorry, of course I should have included code!
GML:
//oPlayer Step Event
key_left = keyboard_check(vk_left);
key_right = keyboard_check(vk_right);
key_jump = keyboard_check_pressed(vk_space);
key_jump_held = keyboard_check(vk_space);
var move = key_right - key_left;
hsp = move * walksp;
vsp += grv;
if place_meeting(x,y+1,oWall) && key_jump
{
vsp = -jumpspeed;
}
//Creates an object to mark when I press the jump button
if key_jump instance_create_layer(x,y,"Player",oPlayerMarker);
if (vsp < 0) && (!key_jump_held) && !bounced
{
vsp = max(vsp,-jumpspeed/4)
}
//horizontal collision
if (place_meeting(x+hsp,y,oWall))
{
while !(place_meeting(x+sign(hsp),y,oWall))
{
x += sign(hsp);
}
hsp = 0;
}
x += hsp;
//vertical collision
if (place_meeting(x,y+vsp,oWall))
{
while !(place_meeting(x,y+sign(vsp),oWall))
{
y += sign(vsp);
}
vsp = 0;
bounced = false;
}
if move > 0
{
movingright = true;
movingleft = false;
}
if move < 0
{
movingleft = true;
movingright = false;
}
if keyboard_check_pressed(ord("V")) && movingright == true instance_create_layer(x+30,y,"Player",oAttackRight);
if keyboard_check_pressed(ord("V")) && movingleft == true instance_create_layer(x-30,y,"Player",oAttackLeft);
y += vsp;
Last edited by a moderator: