• 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!

Legacy GM Using semicolon in-game

D

danzibr

Guest
I have a 2-player game where WASD is used for movement for player 1, and I'd like OKL; to be used for movement for player 2, but I can't get ; to work. vk_semicolon doesn't seem to be built-in, so I tried keyboard_check(ord(';')) and got nothing. Is there a way to get this to work? I'd really rather not use the arrow keys.

Oh, it's compatible with XBox controllers, and that's how I intend it to be played, but I want to give people the option to use the keyboard, too.
 

GMWolf

aka fel666
i think GM uses the ascii codes (but dont quote me on that), so you can try using that ( 59 for ';')
You can also find out what the code is by adding the following code in the keypress_any key event and pressing the ';' key
Code:
show_message(string(keyboard_key));
as a side note, most web games i have played with 2 players using a WASD configuration would either use the arrow keys or the numpad for player 2.
But because of different international keyboards and smaller keyboards (missing numpads) I suggest you use keymappings :)
 
R

rui.rosario

Guest
There is a problem I identify with the semicolon key (mainly because it affects me) and that probably is the reason behind the missing vk_semicolon:
I have a Portuguese keyboard, and if I use keyboard_check(ord(';')) then it gets mapped to the wrong key (I tested this a few months ago, so I don't remember if it gets mapped to a different key right off the Portuguese Layout or when I change to the English Layout and since I tested it some time ago I don't remember all the details).

Most people use a QWERTY keyboard, and it is guaranteed that the arrow keys, the letters and the number will (to a certain degree) be all in the same place/mapping. However other keys can change due to language purposes (the Portuguese layout for instance has some keys due to accents on words). This means those volatile keys shouldn't be used for the game controls unless you can adapt to the layout in question dynamically.

Since you use the WASD scheme I would suggest using the IJKL for the second player, as it would also have a similar key placing, only that it would be on the right side of the keyboard instead of the left side.
 
S

Snail Man

Guest
Is the semicolon really necessary, or could you use another key? It seems unreliable with keyboard layouts, and it might be better to just shift all your controls one key to the left.
 
O

Opticrow

Guest
Put this in some step event:
Code:
if keyboard_lastkey != 0
   {
   show_message("Keyboard ID: " + string(keyboard_lastkey));
   keyboard_lastkey = 0;
   }
and then press the ; key. Whatever value it is, put it in your keyboard check :D

Code:
keyboard_check( val );
But don't use vk_ or ord() here, as those are for converting standard keys into that number!
 

Yal

🐧 *penguin noises*
GMC Elder
Most keyboards for languages with special characters put those characters to the right of P/L/M, so using the semicolon key for something you want to distribute is kinda risky... for instance, on my swedish keyboard, the semicolon key is BELOW K and L, with an Ö key to the right of L. Is there any particular reason you can't use IJKL instead?
 
R

rui.rosario

Guest
Most keyboards for languages with special characters put those characters to the right of P/L/M, so using the semicolon key for something you want to distribute is kinda risky... for instance, on my swedish keyboard, the semicolon key is BELOW K and L, with an Ö key to the right of L. Is there any particular reason you can't use IJKL instead?
On my Portuguese keyboard ';' is located next to M (you need to Shift to write it, because the normal key is ',') and to the right of the L I have Ç
 
On my Portuguese keyboard ';' is located next to M (you need to Shift to write it, because the normal key is ',') and to the right of the L I have Ç
Hang on, if you have to use Shift to get the semi-colon ';' and the normal (un-shifted) key is actually the comma ',' then shouldn't you be checking for the comma in your code instead of the semi-colon?

Or am I just completely not understanding at all (which is quite possible)?
 
R

rui.rosario

Guest
Hang on, if you have to use Shift to get the semi-colon ';' and the normal (un-shifted) key is actually the comma ',' then shouldn't you be checking for the comma in your code instead of the semi-colon?

Or am I just completely not understanding at all (which is quite possible)?
I'm giving an example of why the use of keys like ';' for game controls should be discouraged, unless some keyboard layout defensive code was taken into action.

As far as checking for it goes, it would still depend on the layout. Maybe for Portuguese layouts checking for ',' would work, but when you tried it with another it would fail again.
 
I'm giving an example of why the use of keys like ';' for game controls should be discouraged, unless some keyboard layout defensive code was taken into action.

As far as checking for it goes, it would still depend on the layout. Maybe for Portuguese layouts checking for ',' would work, but when you tried it with another it would fail again.
True. I try to stay away from any non-alphanumeric keys for the majority of stuff. Function keys I'll use too but other than those I just won't touch.

Why not just allow the end user to choose their own keybinds? :D
Definitely agree with this.
 

Nehemek

Member
Yep, the best advice is to have a key bindings menu, for the reason that although letters are more reliable across multiple languages there are still variations of key placement on a single language (see AZERTY keyboard layout which is also for english).
 
D

danzibr

Guest
Forgot to check the thread for a bit, all the responses! Thanks everyone. I ended up doing doing keyboard_check(186).

As for the OKL; business, I more or less need it because on the left hand I have F and G for different attacks, and the right hand has J and H. But really, it's not a crisis. It's meant to be played with controllers anyway.
 
Top