Legacy GM Jumping Error

G

gamedragonify

Guest
I'm having a problem where if I hold left, up, and press the jump button, my character won't jump. Just holding left and jumping works, holding up and jumping works, holding right and jumping works, and holding right and up and jumping works.

This is the code I used, I've been through it a hundred times but can't find the problem with it. Can anyone here help me?

Code:
key_right = keyboard_check(vk_right);
key_left = -keyboard_check(vk_left);
key_jump = keyboard_check_pressed(vk_space);

//React to inputs

if(can_move = true)
{
    move = key_left + key_right;
    hsp = move * movespeed;
}

if (vsp < 10) vsp += grav;
if (place_meeting(x,y+1,obj_wall))
{
    jumps = maxjumps
    rising_spark = 1
}

if key_jump && (jumps > 0)
    {
    jumps -= 1;
    vsp = key_jump * -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;
}
x += hsp;

//Vertical Collision
if (place_meeting(x,y+vsp,obj_wall))
{
    while(!place_meeting(x,y+sign(vsp),obj_wall))
    {
        y += sign(vsp);
    }
    vsp = 0;
}
y += vsp;

   
//Arrow Keys

if keyboard_check(vk_right) && can_move = true
    {
    sprite_index = Player_Walk_R1;
    }
   
if keyboard_check_released(vk_right)
    {
    sprite_index = Player_Stand_R
    }
   
if keyboard_check(vk_left) && can_move = true
    {
    sprite_index = Player_Walk_L
    }
   
if keyboard_check_released(vk_left)
    {
    sprite_index = Player_Stand_L
    }
   
//Attacking

if keyboard_check_pressed(ord("Z")) && sprite_index = Player_Stand_R
{
    sprite_index = Player_PunchR;
    can_move = false;
    alarm_set(0,6)
}
   
if keyboard_check_pressed(ord("Z")) && sprite_index = Player_Walk_R1
{
    sprite_index = Player_PunchR;
    can_move = false;
    alarm_set(0,6)
}

if keyboard_check_pressed(ord("Z")) && sprite_index = Player_Stand_L
{
    sprite_index = Player_PunchL;
    can_move = false;
    alarm_set(1,6)
}

if keyboard_check_pressed(ord("Z")) && sprite_index = Player_Walk_L
{
    sprite_index = Player_PunchL;
    can_move = false;
    alarm_set(1,6)
}

//Specials

if keyboard_check_pressed(ord("X")) && sprite_index = Player_Stand_R && can_shoot = true
    {
    instance_create(Player.x,Player.y,obj_arrowR);
    can_shoot = false;
    alarm_set(2,15);
    }

if keyboard_check_pressed(ord("X")) && sprite_index = Player_Walk_R1 && can_shoot = true
    {
    instance_create(Player.x,Player.y,obj_arrowR);
    can_shoot = false;
    alarm_set(2,15);
    }
   
if keyboard_check_pressed(ord("X")) && sprite_index = Player_Stand_L && can_shoot = true
    {
    instance_create(Player.x,Player.y,obj_arrowL);
    can_shoot = false;
    alarm_set(2,15);
    }

if keyboard_check_pressed(ord("X")) && sprite_index = Player_Walk_L && can_shoot = true
    {
    instance_create(Player.x,Player.y,obj_arrowL);
    can_shoot = false;
    alarm_set(2,15);
    }

if keyboard_check_pressed(ord("X")) && keyboard_check(vk_up) && rising_spark > 0
    {
    sprite_index = rising;
    vsp = -50
    can_move = false
    alarm_set(0,6)
    rising_spark -= 1;
    }
 
R

Ryzzax

Guest
Actually, I have a pretty similar problem too... In my game, I can't shoot (space key) while I'm pressing the up and left key in the same time. But pressing up and right key works with shooting. weird...
 

Ralucipe

Member
GMCJam Champ
This isn't a code issue, it's a keyboard issue. You have a very old keyboard with hardware limitations that is preventing you from detecting the additional keypresses.

You could try remapping to WASD instead of arrows although I'm not sure if this will fix it.

Best option is just to buy an anti-ghosting keyboard (most modern keyboards do it)
 
R

Ryzzax

Guest
ohh
sooo... I guess this is kinda of a good news then ^^
Which means other people that will play our game won't have this kind of problem, right? I hope so ^^
 

Ralucipe

Member
GMCJam Champ
Yes, but if you're going into game dev you need a good keyboard for reliable balanced testing.
 
Top