added simple mode

This commit is contained in:
logsol 2014-12-09 15:55:28 +01:00
parent 1e233efbea
commit 0a0b3e8849
3 changed files with 26 additions and 6 deletions

View file

@ -15,6 +15,7 @@ function (Parent, KeyboardInput, DomController, Settings, Swiper) {
this.y = 0; this.y = 0;
this.modifier = false; this.modifier = false;
this.swiper = null; this.swiper = null;
this.lastLookDirection = 1;
this.playerController = playerController; this.playerController = playerController;
this.keyboardInit(); this.keyboardInit();
@ -58,10 +59,10 @@ function (Parent, KeyboardInput, DomController, Settings, Swiper) {
return self.playerController[methodName].bind(self.playerController); return self.playerController[methodName].bind(self.playerController);
} }
this.keyboardInput.registerKey(keys.a, bind2Pc('moveLeft'), bind2Pc('stop')); this.keyboardInput.registerKey(keys.a, this.moveLeft.bind(this), bind2Pc('stop'));
this.keyboardInput.registerKey(keys.left, bind2Pc('moveLeft'), bind2Pc('stop')); this.keyboardInput.registerKey(keys.left, this.moveLeft.bind(this), bind2Pc('stop'));
this.keyboardInput.registerKey(keys.d, bind2Pc('moveRight'), bind2Pc('stop')); this.keyboardInput.registerKey(keys.d, this.moveRight.bind(this), bind2Pc('stop'));
this.keyboardInput.registerKey(keys.right, bind2Pc('moveRight'), bind2Pc('stop')); this.keyboardInput.registerKey(keys.right, this.moveRight.bind(this), bind2Pc('stop'));
this.keyboardInput.registerKey(keys.w, bind2Pc('jump'), bind2Pc('jumpStop')); this.keyboardInput.registerKey(keys.w, bind2Pc('jump'), bind2Pc('jumpStop'));
this.keyboardInput.registerKey(keys.up, bind2Pc('jump'), bind2Pc('jumpStop')); this.keyboardInput.registerKey(keys.up, bind2Pc('jump'), bind2Pc('jumpStop'));
this.keyboardInput.registerKey(keys.space, bind2Pc('jump'), bind2Pc('jumpStop')); this.keyboardInput.registerKey(keys.space, bind2Pc('jump'), bind2Pc('jumpStop'));
@ -82,6 +83,22 @@ function (Parent, KeyboardInput, DomController, Settings, Swiper) {
); );
}; };
KeyboardAndMouse.prototype.moveLeft = function() {
if (!this.modifier) {
this.lastLookDirection = -1;
this.onXyChange(this.lastLookDirection * Settings.VIEWPORT_LOOK_AHEAD, 0);
}
this.playerController.moveLeft()
};
KeyboardAndMouse.prototype.moveRight = function() {
if (!this.modifier) {
this.lastLookDirection = 1;
this.onXyChange(this.lastLookDirection * Settings.VIEWPORT_LOOK_AHEAD, 0);
}
this.playerController.moveRight();
};
KeyboardAndMouse.prototype.mouseInit = function() { KeyboardAndMouse.prototype.mouseInit = function() {
var canvas = DomController.getCanvas(); var canvas = DomController.getCanvas();
var self = this; var self = this;
@ -141,6 +158,8 @@ function (Parent, KeyboardInput, DomController, Settings, Swiper) {
this.y = -1; this.y = -1;
} }
this.lastLookDirection = this.x >= 0 ? 1 : -1;
this.onXyChange(this.x, this.y); this.onXyChange(this.x, this.y);
}; };
@ -164,7 +183,7 @@ function (Parent, KeyboardInput, DomController, Settings, Swiper) {
KeyboardAndMouse.prototype.deactivateModifier = function() { KeyboardAndMouse.prototype.deactivateModifier = function() {
this.modifier = false; this.modifier = false;
this.x = 0.3; this.x = this.lastLookDirection * Settings.VIEWPORT_LOOK_AHEAD;
this.y = 0; this.y = 0;
this.onXyChange(this.x, this.y); this.onXyChange(this.x, this.y);
}; };

View file

@ -11,7 +11,7 @@ function (Parent, Settings, Nc) {
// View uses this to calculate center position // View uses this to calculate center position
this.lookAtXY = { this.lookAtXY = {
x: 0.3, x: Settings.VIEWPORT_LOOK_AHEAD,
y: 0 y: 0
} }

View file

@ -45,6 +45,7 @@ define(function() {
HEALTH_DISPLAY_TIME: 2, HEALTH_DISPLAY_TIME: 2,
RAGDOLL_DESTRUCTION_TIME: 20, RAGDOLL_DESTRUCTION_TIME: 20,
VIEWPORT_SPEED_FACTOR: 640, VIEWPORT_SPEED_FACTOR: 640,
VIEWPORT_LOOK_AHEAD: 0.1,
// restitution: bouncyness, friction: rubbing, density: mass // restitution: bouncyness, friction: rubbing, density: mass
TILE_FRICTION: 0.99, TILE_FRICTION: 0.99,