The 3 basic windows keyboard messages as passed on;
- key down
- key up
To go with this there are 3 translation tables;
- bonsai.Event.translate does int => string translation
- bonsai.Event.keycodes does string => int translation
- bonsai.Event.charTranslate also does int => string but the output is printable
The first two are mostly useful for game input, for example you could define the following somewhere
up = w
down = s
left = a
right = d
fire = space
Then, by performing a lookup against the current keycodes you can get the required values to check on event handling.
Then when you save out the config you can just push the keycodes into the translate table and get back the string which will translate back to it.
Simple and pretty easy [smile]
The 'bonsai.Event.charTranslate' does printable translations, namely for when shift matters [grin]
So, typing 'a' and typing 'A' will give you the correct results.
However, if you try to type '!' it kinda blows up atm, that's mostly due to the lack of translation causing 'nil' to be appended to my string which I try to print with the following main loop;
quit = false
while(quit == false)
events = bonsai.getEvents()
for i = 1, #events
if events.message == bonsai.Event.types.quit
quit = true
if events.message == bonsai.Event.types.char
text = text .. bonsai.Event.charTranslate[events.param1]
This is just a basic test of things, and I'm pretty happy with it. I should probably fix that exploding translation problem so it does the Right Thing(tm) and I'm also going to have to do something about the shift characters depending on the keyboard layout in use (damn you non-UK layout people! *shakes fists*).
However, that's another tick on my 'todo' list done, huzzah!
I think that pretty much leaves colour constants and sprites to deal with and then the game can be recreated.