Browse Source

camera and pather speed is now based on a new event instead of sprintChance changes...not ideal

tags/v0.6^2
Shaun 4 years ago
parent
commit
f77151c0ce
2 changed files with 13 additions and 11 deletions
  1. +6
    -5
      src/client/js/components/keyboardMover.js
  2. +7
    -6
      src/client/js/rendering/renderer.js

+ 6
- 5
src/client/js/components/keyboardMover.js View File

@@ -17,7 +17,7 @@ define([

init: function () {
this.hookEvent('onCanvasKeyDown', this.onCanvasKeyDown.bind(this));
this.hookEvent('onGetStats', this.onGetStats.bind(this));
this.hookEvent('onMoveSpeedChange', this.onMoveSpeedChange.bind(this));
},

update: function () {
@@ -33,10 +33,11 @@ define([
},

//Changes the moveCdMax variable
// sprintChance: 0 | moveCdMax: 8
// sprintChance: 200 | moveCdMax: 4
onGetStats: function ({ sprintChance = 0 }) {
this.moveCdMax = Math.ceil(4 + (((200 - sprintChance) / 200) * 4));
// moveSpeed is affected when mounting and unmounting
// moveSpeed: 0 | moveCdMax: 8
// moveSpeed: 200 | moveCdMax: 4
onMoveSpeedChange: function (moveSpeed) {
this.moveCdMax = Math.ceil(4 + (((200 - moveSpeed) / 200) * 4));
},

onCanvasKeyDown: function (keyEvent) {


+ 7
- 6
src/client/js/rendering/renderer.js View File

@@ -77,7 +77,7 @@ define([

events.on('onGetMap', this.onGetMap.bind(this));
events.on('onToggleFullscreen', this.toggleScreen.bind(this));
events.on('onGetStats', this.adaptCameraMoveSpeed.bind(this));
events.on('onMoveSpeedChange', this.adaptCameraMoveSpeed.bind(this));

let zoom = isMobile ? 1 : window.devicePixelRatio;
this.width = $('body').width() * zoom;
@@ -825,15 +825,16 @@ define([
},

//Changes the moveSpeedMax and moveSpeedInc variables
// sprintChance: 0 | moveSpeedMax: 1.5 | moveSpeedInc: 0.5
// sprintChance: 200 | moveSpeedMax: 5.5 | moveSpeedInc: 0.2
// moveSpeed changes when mounting and unmounting
// moveSpeed: 0 | moveSpeedMax: 1.5 | moveSpeedInc: 0.5
// moveSpeed: 200 | moveSpeedMax: 5.5 | moveSpeedInc: 0.2
// Between these values we should follow an exponential curve for moveSpeedInc since
// a higher chance will proc more often, meaning the buildup in distance becomes greater
adaptCameraMoveSpeed: function ({ sprintChance }) {
const factor = Math.sqrt(sprintChance);
adaptCameraMoveSpeed: function (moveSpeed) {
const factor = Math.sqrt(moveSpeed);
const maxValue = Math.sqrt(200);

this.moveSpeedMax = 1.5 + ((sprintChance / 200) * 3.5);
this.moveSpeedMax = 1.5 + ((moveSpeed / 200) * 3.5);
this.moveSpeedInc = 0.2 + (((maxValue - factor) / maxValue) * 0.3);
},



Loading…
Cancel
Save