mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
moved files towards new structure. fixes #22
This commit is contained in:
parent
8cf8f057bb
commit
9de3147406
40 changed files with 0 additions and 110 deletions
94
app/game/Client/Control/KeyboardController.js
Executable file
94
app/game/Client/Control/KeyboardController.js
Executable file
|
|
@ -0,0 +1,94 @@
|
|||
define(["Chuck/Control/InputController", "Chuck/Control/KeyboardInput"], function(InputController, KeyboardInput){
|
||||
|
||||
function InputControlUnit(me, clientProcessor) {
|
||||
|
||||
this.clientProcessor = clientProcessor;
|
||||
this.inputController = new InputController(me);
|
||||
|
||||
this.keyboardInput = new KeyboardInput(this);
|
||||
|
||||
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(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() {
|
||||
this.inputController.moveLeft();
|
||||
this.clientProcessor.sendGameCommand('moveLeft');
|
||||
}
|
||||
|
||||
InputControlUnit.prototype.moveRight = function() {
|
||||
this.inputController.moveRight();
|
||||
this.clientProcessor.sendGameCommand('moveRight');
|
||||
}
|
||||
|
||||
InputControlUnit.prototype.stop = function() {
|
||||
this.inputController.stop();
|
||||
this.clientProcessor.sendGameCommand('stop');
|
||||
}
|
||||
|
||||
InputControlUnit.prototype.jump = function() {
|
||||
this.inputController.jump();
|
||||
this.clientProcessor.sendGameCommand('jump');
|
||||
}
|
||||
|
||||
InputControlUnit.prototype.jumped = function() {
|
||||
this.inputController.jumped();
|
||||
}
|
||||
|
||||
InputControlUnit.prototype.jumping = function() {
|
||||
this.inputController.jumping();
|
||||
}
|
||||
|
||||
InputControlUnit.prototype.duck = function() {
|
||||
this.inputController.duck();
|
||||
this.clientProcessor.sendGameCommand('duck');
|
||||
}
|
||||
|
||||
InputControlUnit.prototype.standUp = function() {
|
||||
this.inputController.standUp();
|
||||
}
|
||||
|
||||
InputControlUnit.prototype.activateShift = function() {
|
||||
this.inputController.activateShift();
|
||||
this.clientProcessor.sendGameCommand('activateShift');
|
||||
}
|
||||
|
||||
InputControlUnit.prototype.deactivateShift = function() {
|
||||
this.inputController.deactivateShift();
|
||||
}
|
||||
|
||||
InputControlUnit.prototype.update = function() {
|
||||
this.keyboardInput.update();
|
||||
}
|
||||
|
||||
return InputControlUnit;
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue