summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMadeline <60828599+vesindolen@users.noreply.github.com>2020-12-05 19:58:05 -0500
committerGitHub <noreply@github.com>2020-12-05 19:58:05 -0500
commitfdd7ef7d421ca3c1c629349a8aeef700583576ed (patch)
tree891c3738299d12b51c0d4356768ee6729c8b799f
parentbe9d1afdfff956e84940ae91615ec06af70e1e16 (diff)
Buffered walking
but actually this time Single presses will be scheduled for the next walk.
-rw-r--r--public/javascript/game.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/public/javascript/game.js b/public/javascript/game.js
index cf81629..95a0518 100644
--- a/public/javascript/game.js
+++ b/public/javascript/game.js
@@ -80,6 +80,8 @@ var gameUpdateSocket;
var gameUpdateStartTimestamp;
var moduleList = [];
+var localPlayerWalkBuffer = -1; // no buffering
+
// Thanks to CatTail for this snippet of code.
var encodeHtmlEntity = function(str) {
var buf = [];
@@ -1196,6 +1198,7 @@ function localPlayerStartWalking(direction) {
{
localPlayer.walk(direction);
localPlayerWalkRepeatDirections.push(direction);
+ localPlayerWalkBuffer = direction;
}
//localPlayerWalkRepeatDelay = 0.1 * framesPerSecond;
//localPlayerShouldStopWalkRepeat = !lKeyIsHeld;
@@ -1554,10 +1557,15 @@ function timerEvent() {
}
}
}
- if (localPlayerWalkRepeatDirections.length > 0) {
+ if (localPlayerWalkRepeatDirections.length > 0 || localPlayerWalkBuffer >= 0) {
if (localPlayerWalkRepeatDelay > 0) {
localPlayerWalkRepeatDelay -= 1;
- } else {
+ }
+ else if (localPlayerWalkBuffer >= 0) {
+ localPlayer.walk(localPlayerWalkBuffer);
+ localPlayerWalkBuffer = -1;
+ }
+ else {
localPlayer.walk(localPlayerWalkRepeatDirections[localPlayerWalkRepeatDirections.length - 1]);
}
}