1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

No mouse input possible with WASD keys movement

Discussion in 'Programming' started by PixelPluto, Dec 30, 2018.

  1. PixelPluto

    PixelPluto Member

    Joined:
    Sep 1, 2018
    Posts:
    15
    So I played around a bit with Shaun Spalding's arena shooter tutorial (GML), and wanted to use the WASD keys for the movement instead of the arrow keys.

    I then noticed that, when I press the WASD keys and the player is moving, the mouse pointer isn't moving at all, and while moving, I also cannot shoot (which happens by clicking the left mouse button). As soon as the player stops, the mouse pointer moves again and and I can shoot. As soon as the player moves, it's not working anymore.

    I searched on the web for a solution to this, but unfortunately couldn't find anything. I also tried to find a work-around, but shouldn't the WASD keys work just the same way as the arrow keys?

    Does someone else have the same issue? Could this be a bug?
     
  2. Paskaler

    Paskaler Member

    Joined:
    Jul 4, 2016
    Posts:
    316
    Maybe the problem is somewhere else in the code here. Maybe, while changing you modified some condition or something.

    It would be helpful if you posted the code for the movement
     
  3. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,986
    For the movement AND the aiming
     
    Paskaler likes this.
  4. PixelPluto

    PixelPluto Member

    Joined:
    Sep 1, 2018
    Posts:
    15
    I have this code in the player object, the Step event:

    // Player movement (arrow keys)
    //if (keyboard_check(vk_right)) x = x + 4;
    //if (keyboard_check(vk_left)) x = x - 4;
    //if (keyboard_check(vk_up)) y = y - 4;
    //if (keyboard_check(vk_down)) y = y + 4;

    //Player movement (WASD)
    if (keyboard_check(ord("A"))) x = x - 4;
    if (keyboard_check(ord("D"))) x = x + 4;
    if (keyboard_check(ord("W"))) y = y - 4;
    if (keyboard_check(ord("S"))) y = y + 4;

    //Player towards mouse position
    image_angle = point_direction(x, y, mouse_x, mouse_y);

    // Create bullets, slow down bullets
    if (mouse_check_button(mb_left)) && (bullet_slow < 1)
    {
    instance_create_layer(x, y, "ly_bullets", obj_bullet)
    bullet_slow = 4;
    }

    bullet_slow = bullet_slow - 1;


    And this code in the bullet object, Create event:

    // Shooting from player object
    direction = point_direction(x, y, mouse_x, mouse_y);
    direction = direction + random_range(-4, 4);
    speed = 16;
    image_angle = direction;

    I just did how Shaun Spaulding showed it in his tutorial.
     
  5. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,986
    When you say mouse pointer, are you talking about that little arrow that Windows has, or are you talking about a custom cursor that you use? At this point it sounds like there's a problem with your computer.
     
  6. PixelPluto

    PixelPluto Member

    Joined:
    Sep 1, 2018
    Posts:
    15
    Yes, I mean the little arrow that Windows has...

    If it's really my computer, I'll try the game on another computer.
     
  7. PixelPluto

    PixelPluto Member

    Joined:
    Sep 1, 2018
    Posts:
    15
    I develop my games on a laptop, and it's probably the laptop's touchpad/left button that's not working with WASD. I plugged a USB mouse to the laptop, and then, the mouse worked with the WASD keys.

    I tried it on a second laptop that I have, and the same problem occured: touchpad/left button of the laptop to shoot isn't working while pressing WASD, but it worked with the USB mouse.

    Now I'm not really sure what to do about this...
     
  8. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,986
    Customize controls
     
  9. PixelPluto

    PixelPluto Member

    Joined:
    Sep 1, 2018
    Posts:
    15
    Well, I'll see what I can/will do.

    Anyways, thank you all for your replies :) !
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice