• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML Keyboard Remapping - GMWolf

GMWolf

aka fel666
GM Version: GameMaker studio and Studio 2
Target Platform: ALL
Download: N/A
Links: Video Link


Summary:
As introduced in the video, Keyboard mapping can be done using variables, but it can be quite a limmiting technique.
Thankfully GM includes a set of functions made specifically to deal with Keymappings.
Tutorial:
Check out my Channel on Youtube for more tutorials!
 

poliver

Member
Would this be useful for in-game remapping like custom controls?

For something simpler id personally stick with variables though with using max. like
Code:
key_up = max("ord_W", vk_up);
 

GMWolf

aka fel666
Would this be useful for in-game remapping like custom controls?
Yes, This would work very well for custom controls/
For something simpler id personally stick with variables though with using max. like
Code:
key_up = max("ord_W", vk_up);
Im not sure you understand what max does.
If you do that only one of the two keys will work, (which ever has the higher keycode).
Perhaps you meant to use keyboard_check along with max?
 

poliver

Member
Yes, This would work very well for custom controls/
Nice! already can see a use for that in my projects! ive tried it before with simulating keys but this looks simpler.
Perhaps you meant to use keyboard_check along with max?
oh yeah, that's what i meant! :D there's downside to that that it will only apply to specific keyboard function, true.
 
Last edited:

GMWolf

aka fel666
oh yeah, that's what i meant!
In that case its much easier to use what I outlined early in the video:
Code:
key_up = keyboard_check(vk_up) || keyboard_check(ord("W"));
The or operator, ||, Is more appropriate as we are dealing with booleans.

However i would still recommend the use of the key mapping functions, as they can be more flexible.
 

GMWolf

aka fel666
correct me if im wrong, but would that even work? isnt that same as trying to do something like
Code:
variableA = 1 || 2
keyboard_check will return true if the key is pressed, false if it isn't.
side note -> in GML, true and false are just numbers, but that doesn't matter for now.

SO no, its not like doing 1 || 2, since keyboard_check is an actual function that returns different values based on state.
 
S

Snayff

Guest
Fel, thank you for another tutorial! I imagine it will be as high a standard as ever and I look forward to watching.
 
Top