Post Modern Game Input
JSConf 2013
Gaming?
HTML5 gives us a bunch of lego pieces to connect together and build really cool things.
Game Loop
window.requestAnimationFrame(). 60 times/second
Keyboard
if(im.keyActions[keys.LEFT_ARROW].isPressed()){
//move the player to the left
}
Mouse / Touch
//mobile first :)
var position = im.touchAction.position || im.mouseAction.position;
Gestures
//hamer code
Demo
Gamepads
navigator.webkitGetGamepads();
Gamepad Polling
Just check the gamepad state.
Demo
Phone as a Gamepad
There's an app for that...
yay itunes, yay google play
It's called a Browser
demo
You have to use your hands?
That's like a baby's toy.
Camera Face Tracking
Donut Horns made by B-Reel for Google hangouts
Web Speech API
new webkitSpeechRecognition();
Demo
Leap Motion
WebSockets !
bindings for Java, CSharp, python...
leap.js
var controller = new Leap.Controller({enableGestures:true});
controller.on('frame', function(frame) {
game.pointables = frame.pointables;
});
controller.connect();
Demo
But I want to wear a controller...
Connect ALL the things.
Websockets are your glue.