GameMaker How To Check If Two Keys Are Pressed At Same Time
Вставка
- Опубліковано 21 жов 2024
- GameMaker tutorial / lesson with completed project files at gameprogrammingcourse.com in the RESOURCES section.
Sometimes you need to know if the player is pressing down two or more keys at once. A good example is for diagonal movement, or for special player abilities. This video shows you a simple way to code this.
Check out hundreds of other GameMaker tutorials and lessons at GameProgrammingCourse.com
All these gamemaker tutorials will work with Gamemaker Studio GMS or Gamemaker Studio 2 GMS.
Go to the Resource Page of www.gameprogram... to download the Project Files for these tutorials!
Thank you,
I used this code after editing it a bit, to make it so my ship shoots both engines at once when both arrows are pressed.
Thanks. And nice voice btw :)
what code do you do to make it so an object moves diagonally
+Jomy Jonathan For diagonal up and right just check if the UP and RIGHT arrow keys are pressed (or whichever keys you are using). If they are then set the direction of the object with direction=45. You'll have to go through all 8 direction key combo's. Watch out for the order of your IF/ELSE IF's to make sure that you don't check for RIGHT ONLY first and get the player moving rightward thereby missing the UP AND RIGHT key combo - easy beginner error to make.
thanks!
btw it worked when I tried it so... DOUBLE THANKS!!!
Good to know that info about the sequencing. It helped me out.
So in my game I need to check if the player presses enter when solving a math problem, and I have to check to see if the player pressed enter when entering an answer or not entering anything. Help? This is what I have so far: if 'text' == " " && keyboard_key = vk_enter
for Windows programs there is a game maker method that will allow the user to enter some text. You can look this up in the help file. If you want the user to enter text on any other platform, you will actually have to construct some type of keyboard input for the player. This is not a quick task. I suggest you lookup tutorials on creating keyboard input. but like I said, if it's just for the windows platform, use the built-in method in gamemaker to get text input from the user.
Thank you :)
Cool, thanks.