0
\$\begingroup\$
///Get player's input
key_right = keyboard_check(vk_right);
key_left = -keyboard_check(vk_left);
key_jump = keyboard_check_pressed(vk_space);
key_jump_held = keyboard_check(vk_space);
key_shoot = keyboard_check(ord("D"));

//React to inputs
move = key_left + key_right;
hsp = move * movespeed;
if (vsp < 10) vsp += grav;

if (place_meeting(x, y+1, Obj_Floor))
{
 vsp = key_jump * -jumpspeed;
}

if (vsp < 0) && (!key_jump_held) vsp = max(vsp,0)

//Horizontal Collision
if (place_meeting(x+hsp, y, Obj_Floor))
{
 while(!place_meeting(x+sign(hsp), y, Obj_Floor))
 {
  x += sign(hsp);
 }
 hsp = 0;
}
x += hsp;

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

//Animate
if (move != 0) 
{
 image_xscale = move;
}

if (place_meeting(x, y+1, Obj_Floor))
{

 if (move != 0) 
 { 
  sprite_index = CalvinWalking;
  image_speed = 0.07;
 } 

 else 
 {
  sprite_index = CalvinStanding;
  image_speed = 0.025;
 }
}

else
{
 if (vsp < 0) sprite_index = CalvinJumping
 else sprite_index = CalvinJumping
}

and

///Shooting with D
//Shooting direction
if (keyboard_check(vk_right))
{
 mpfacing = 0;
}

if (keyboard_check(vk_left))
{
 mpfacing = 180;
}

if (keyboard_check(vk_up))
{
 mpfacing = 90;
}

//Shooting
if (keyboard_check(ord("D"))) && (canshoot = true)
{
 instance_create(x+13, y-0.5, Obj_MP_Laser);
 canshoot = false;
 alarm[1] = 30;
}

is my code but for some reason when i press up, and move left, i can't jump when i press space. Which i don't understand because i can jump when moving left, and when i press up, but not when i press both.

\$\endgroup\$
  • \$\begingroup\$ Standard sanity test: does it work if you replace space with, say, Z? Many keyboards have trouble registering multiple keys with the spacebar. \$\endgroup\$ – Quentin Apr 16 '18 at 11:59
  • \$\begingroup\$ When i changed space to S it works, but i wanted it to be space though. \$\endgroup\$ – Gameboy The Collector Apr 17 '18 at 11:47
  • 1
    \$\begingroup\$ Then unfortunately it's a hardware problem. You'll need a keyboard with N-key rollover (NKRO) to avoid these limitations. \$\endgroup\$ – Quentin Apr 17 '18 at 11:50
  • \$\begingroup\$ I'll just change the controls for jump and shoot to z and x and hope it's ok. However, thank you so much, at least the problem is now fixed now \$\endgroup\$ – Gameboy The Collector Apr 17 '18 at 12:05
0
\$\begingroup\$

Apparently using any other button other than space works, because the space key has trouble working with multiple buttons. Literally, using any other button fixed it.

\$\endgroup\$
  • \$\begingroup\$ This may be very dependent on the keyboard used. Other users of the game may run into the same problem you were having earlier with this new layout. Trying to find resources now on this, but can't remember the appropriate search term. When I ran into this problem with my game, we just bit the bullet and hoped it wouldn't affect people too significantly. \$\endgroup\$ – Jeff Apr 19 '18 at 2:10
  • \$\begingroup\$ ok but the keyboard i have is top quality so i assume not many people have the keyboard to do so \$\endgroup\$ – Gameboy The Collector Apr 20 '18 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.