ippa / chingu

OpenGL accelerated 2D game framework for Ruby
http://ippa.se/chingu
GNU Lesser General Public License v2.1
309 stars 66 forks source link

How to listen to semicolon and quote characters #53

Closed samueller closed 12 years ago

samueller commented 12 years ago

I see that chingu maps gosu's keys to nice simple symbols. But there doesn't seem to be a symbol for the semicolon or quote characters (or others I'm sure). I don't know what they would map to for gosu or if gosu takes into account those characters either.

What can I do to listen to semicolon and quote keypresses?

ippa commented 12 years ago

Chingu can only listen to the same keypresses Gosu can. I can't find semicolon or quotes here http://www.libgosu.org/rdoc/Gosu.html .. can I ask what you want them too? Seems like odd keys to use for in game control. I'm pretty sure they'll display using Gosus textinput thingie though.. but that's for freetext input like highscore-names and similar.

samueller commented 12 years ago

I have a game with 2 players at one keyboard (a player using the left side and a player using the right side) to control their characters. I need to make use of keys next to the enter key as much as possible to make it comfortable for the players.

But I can also imagine a game with so many controls that you run out of the letters to easily play the game...

I played around a little with these keys that aren't documented by Gosu, the problem is they are completely different values for Windows vs Mac. I think for Linux this is the case too... not that big of a problem I guess, but a pain.. And I need to figure out how to determine whether the computer is a mac, windows or pc after getting the values of the keys I want. Something I would totally expect the game framework to handle for me.

ippa commented 12 years ago

Couldn't a 2-player game use WASD for player #1 and the arrow-keys for player #2? Or move player #2 even further to the right by using the numpad with Numlock pressed. Maybe you need a lot more keys for your controls.

In either case, if you find undocumented Gosu keyconstants it should be very easy to add them here: https://github.com/ippa/chingu/blob/master/lib/chingu/input.rb .. the code explains itself. I'm on win 7 so I'm not sure what keys differ between mac, linux and windows.

I agree that this is something the framework should handle.. but if Gosu doesn't handle it Chingu can't since it's built upon Gosu.

samueller commented 12 years ago

Gosu is missing a lot of key constants. They're aware of it and asked for patches... If I get time I'll help.