1
if keyboard_check('D')
{
    x = x + 4
    sprite_index = spr_playerRight
}

As soon as I start the game, the player sprite will start moving to the right. But, as you can see, that shouldn't be happening... right?

When I actually do press D, it does the (Else) portion of the little chunk.

Any idea why this is happening? I'm a bit new to this.

Edit: I was messing around a little and I swapped the code (the IF from the else) and I would not move at the start, but pressing any key would cause me to move.

Another Edit: The fact that the Else would apply any time the D key is not applied made me realize that (if this did work properly) the else on this would intrude on attempts to move other directions (Pressing any button will stop the movement)

Another Edit: I changed the keyboard_check to keyboard_check(vk_right) And it works perfectly fine. I believe this is simple a problem on how I declared the key... How do I declare keys properly?

Rob
  • 4,927
  • 4
  • 26
  • 41

1 Answers1

6

According to the documentation it should be:

if keyboard_check(ord('D'))
Paul R
  • 208,748
  • 37
  • 389
  • 560
  • Thank you, Paul. I misread the documentation first time I went over it; I guess I didn't see the 'ord' – user1550744 Jul 25 '12 at 07:04
  • 3
    Please consider accepting and/or upvoting this answer, that way Paul will get precious reputation points for his help and other users will know this question is solved. – Medo42 Jul 25 '12 at 19:45