From 902a7d20562730b7896df9bbd99dd11c21fc869a Mon Sep 17 00:00:00 2001 From: Jeena Paradies Date: Tue, 10 Jul 2012 10:08:55 +0200 Subject: [PATCH] added arrow keys --- lib/Chuck/Control/InputControlUnit.js | 36 +++++++++++++++++++++------ 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/lib/Chuck/Control/InputControlUnit.js b/lib/Chuck/Control/InputControlUnit.js index b19ae70..fa43ee6 100755 --- a/lib/Chuck/Control/InputControlUnit.js +++ b/lib/Chuck/Control/InputControlUnit.js @@ -13,15 +13,37 @@ define(["Chuck/Control/KeyboardInput"], function(KeyboardInput){ this.KEY_UP = 87; this.KEY_DOWN = 83; - this.init(); + var keys = { + w:87, + a:65, + s:83, + d:68, + + up: 38, + left: 37, + down: 40, + right: 39 + } + + this.init(keys); } - InputControlUnit.prototype.init = function() { - this._keyboardInput.registerKey(this.KEY_LEFT, 'moveLeft', 'stop', 'moveLeft'); - this._keyboardInput.registerKey(this.KEY_RIGHT, 'moveRight', 'stop', 'moveRight'); - this._keyboardInput.registerKey(this.KEY_UP, 'jump', 'jumped', 'jumping'); - this._keyboardInput.registerKey(this.KEY_DOWN, 'duck', 'standUp', 'duck'); - this._keyboardInput.registerKey(this.KEY_DOWN, 'activateShift', 'activateShift', 'deactivateShift'); + InputControlUnit.prototype.init = function(keys) { + + this._keyboardInput.registerKey(keys.a, 'moveLeft', 'stop', 'moveLeft'); + this._keyboardInput.registerKey(keys.left, 'moveLeft', 'stop', 'moveLeft'); + + this._keyboardInput.registerKey(keys.d, 'moveRight', 'stop', 'moveRight'); + this._keyboardInput.registerKey(keys.right, 'moveRight', 'stop', 'moveRight'); + + this._keyboardInput.registerKey(keys.w, 'jump', 'jumped', 'jumping'); + this._keyboardInput.registerKey(keys.up, 'jump', 'jumped', 'jumping'); + + this._keyboardInput.registerKey(keys.s, 'duck', 'standUp', 'duck'); + this._keyboardInput.registerKey(keys.down, 'duck', 'standUp', 'duck'); + + this._keyboardInput.registerKey(keys.s, 'activateShift', 'activateShift', 'deactivateShift'); + this._keyboardInput.registerKey(keys.down, 'activateShift', 'activateShift', 'deactivateShift'); } InputControlUnit.prototype.moveLeft = function() {