Integrating Meteor with JavaScript game engines and tracking keyboard input


#1

Doing a bit of experimentation with integrating Meteor with Crafty. Crafty intercepts keydown DOM events to handle keyboard commands. I suppose I can use Meteor instead for this, but I like Crafty’s entity system and would rather it handle game input.

I want to use Meteor for the game UI and maybe multiplayer if it gets that far, but would like Crafty to manage all game interaction. Is there some way to mark a specific element as not participating in Meteor’s keydown/keyup event handling somehow? Or is there another way?

Thanks.


#2

Hi ndarilek!

Good for you - cool idea, integrating with Crafty! Have you actually tried this yet and run into a problem? Or are you afraid to start down the path because you’re concerned about running into something?

I don’t envision there would be a problem - they operate at different layers. If you don’t define any click or key event handlers in the Meteor helpers, I imagine they would be handled just fine by Crafty. Instead, use Meteor to define alternate page layouts (e.g. leaderboard, main menu, in-game, level 1, level 2, etc.), and switch between them reactively. The main core game loop would still run in Crafty.

We did a similar thing with Unity, and the event handling is not a problem. (For that setup, the problem is getting data back and forth between the game client and the Meteor client / web page - you have to build a small pipeline to send messages back and forth, because Meteor sees only an opaque DOM object that it knows nothing about, and the Unity client knows nothing about Meteor. We found a workaround, which you can read about here:
http://ump.voidalpha.com - includes sample source to help you get started. I know you’re not doing Unity, but maybe some of the concepts will be the same?)

Best of luck!
Aaron