Jump to content


Photo

Key Press Check?


  • Please log in to reply
14 replies to this topic

#1 This_Is_Where_My_Name_Goes

This_Is_Where_My_Name_Goes

    GMC Member

  • New Member
  • 7 posts

Posted 01 February 2008 - 04:13 PM

Hello, I am new to Game Maker. I have GM 6. I need a peice of code to tell wither I am pushing the letter "D" or not. Just something simple that I can use in the "if" D&D function. Thanks!
  • 0

#2 crashhelper

crashhelper

    GMC Member

  • GMC Member
  • 872 posts

Posted 01 February 2008 - 04:16 PM

Check the manual.

keyboard_check_press()
  • 0

#3 This_Is_Where_My_Name_Goes

This_Is_Where_My_Name_Goes

    GMC Member

  • New Member
  • 7 posts

Posted 01 February 2008 - 04:20 PM

I couldn't figure out which one I needed in the manual. keyboard_check_press said that it was and unrecognised function or script?
  • 0

#4 crashhelper

crashhelper

    GMC Member

  • GMC Member
  • 872 posts

Posted 01 February 2008 - 04:21 PM

keyboard_check_pressed() sorry
  • 0

#5 This_Is_Where_My_Name_Goes

This_Is_Where_My_Name_Goes

    GMC Member

  • New Member
  • 7 posts

Posted 01 February 2008 - 04:23 PM

Okay this is what I put keyboard_check_pressed(D)
it said that D was an unknown variable?
  • 0

#6 crashhelper

crashhelper

    GMC Member

  • GMC Member
  • 872 posts

Posted 01 February 2008 - 04:26 PM

Of course D is an unknown variable. It hasn't been defined, and is not a constant.

Once again, check the manual.
  • 0

#7 This_Is_Where_My_Name_Goes

This_Is_Where_My_Name_Goes

    GMC Member

  • New Member
  • 7 posts

Posted 01 February 2008 - 04:40 PM

Okay, so you have to put D in "D". Okay so, now it runs, but it still isn't checking if I press D. the code I entered is.
keyboard_check_pressed("D")

What I am making is a little guy who walks back and forth
A = left D = Right

Normally if you release key A you would stop walking left. What I need is if you release key A, but are still pushing key D then the guy will start walking right. does that makes sence? thanks for the help.
  • 0

#8 crashhelper

crashhelper

    GMC Member

  • GMC Member
  • 872 posts

Posted 01 February 2008 - 04:42 PM

It wants the ascii code of the character. ORD() returns the ascii code of the given character, CHR() returns the character of the given ascii code.

keyboard_check_pressed(ord("D"))
  • 0

#9 This_Is_Where_My_Name_Goes

This_Is_Where_My_Name_Goes

    GMC Member

  • New Member
  • 7 posts

Posted 01 February 2008 - 04:46 PM

I tried that and it still doesn't seem to work. Maby I am just missing something.
  • 0

#10 Smurfer

Smurfer

    GMC Member

  • New Member
  • 41 posts

Posted 01 February 2008 - 04:47 PM

I tried that and it still doesn't seem to work.  Maby I am just missing something.

<{POST_SNAPBACK}>


in the step event
if keyboard_check_direct(ord("D"))
{
x+=4
}
if keyboard_check_direct(ord("A"))
{
x-=4
}

  • 0

#11 supreme_boss

supreme_boss

    GMC Member

  • New Member
  • 531 posts

Posted 01 February 2008 - 04:48 PM

ok
its:

keyboard_check_pressed(ord("D"))
It MUST be in caps (the letter)
  • 0

#12 crashhelper

crashhelper

    GMC Member

  • GMC Member
  • 872 posts

Posted 01 February 2008 - 04:48 PM

You have a problem somewhere else in your code then, or your implementation of the function is invalid.
  • 0

#13 This_Is_Where_My_Name_Goes

This_Is_Where_My_Name_Goes

    GMC Member

  • New Member
  • 7 posts

Posted 01 February 2008 - 04:48 PM

Okay thanks. I have to go so I will try it later.
  • 0

#14 Maurits007

Maurits007

    GMC Member

  • New Member
  • 26 posts

Posted 01 February 2008 - 04:51 PM

You can also drag and drop, that is a lot easyer :(
  • 0

#15 Aero88

Aero88

    GMC Member

  • GMC Member
  • 443 posts
  • Version:GM:Studio

Posted 07 February 2008 - 01:09 AM

I think the problem is you need to just put keyboard_check(ord("D")) instead of keyboard_check_pressed or keyboard_check_direct. I think that will fix your problem.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users