I am trying to set up a system where I can map controls to keys. For instance, UP maps to the key A. This is the code:
Local keyControls:= New StringMap<Key>
local k:= keyControls.Get("UP")
Print( "code for UP: " + Keyboard.ScanCode(k) )
Print( "new code: " + Keyboard.ScanCode(k) )
The only thing I get back are zeros. Am I missing something here? Thanks!
At the start of main, I think that initialises a load of stuff in mojo so it’s ready for use.
geez Pete, that is it… Thanks so very much. Valuable lesson!
Although it’s one of those things you don’t forget once you learn it, I feel like it would be a more intuitive/familiar design if instead of using “New AppInstance”, the command was “Mojo.Init()” or “App.Init()” or something like that.
It would be cool if the App.Run() ran automatically somehow as well. Monkey 1’s simplicity of use is a good design target for me.
Actually, I wonder why Mark didn’t create an App class that handles the Window and all the initialization like it does in M1. The new way offers a lot of control, but is also more complex and has more room for error. I feel that it could be an option alongside a simpler M1 style App class as the main option. Maybe it’s planned for the future?
I also found out that App.Run() is also needed to get proper readings for the Keyboard Down and Hit methods. So it is not just the initialization that is required… Something to take away when creating testbeds.
You must be logged in to reply to this topic.
Monkey2 is an easy to use, cross platform, games oriented programming language from Blitz Research.