summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Eisenmann <johneisenmann@Johns-iMac.local>2018-01-15 08:37:36 -0500
committerJohn Eisenmann <johneisenmann@Johns-iMac.local>2018-01-15 08:37:36 -0500
commitb8a5c7c8fd7970fff0e5a90dcfde4a8400c815ae (patch)
tree72240044024c7df73184aab2dfa1b185dd64d5fb
parent69f2a3fb156f7fba8c3ba0e8090172716b3aa52a (diff)
Added more position information
-rw-r--r--public/javascript/game.js10
-rw-r--r--views/game.html5
2 files changed, 14 insertions, 1 deletions
diff --git a/public/javascript/game.js b/public/javascript/game.js
index d66f937..437a5e5 100644
--- a/public/javascript/game.js
+++ b/public/javascript/game.js
@@ -1080,13 +1080,20 @@ function centerSelectedInventoryItem() {
function drawCompass() {
var tempDistance = localPlayer.pos.getDistance(respawnPos);
var tempOffset;
+ var tempAngle;
if (tempDistance > 0) {
tempOffset = respawnPos.copy();
tempOffset.subtract(localPlayer.pos);
+ tempAngle = Math.atan2(tempOffset.x, -tempOffset.y);
+ if (tempAngle < 0) {
+ tempAngle += 2 * Math.PI;
+ }
tempOffset.scale(1 / tempDistance);
} else {
tempOffset = null;
+ tempAngle = 0;
}
+ document.getElementById("respawnAngle").innerHTML = Math.round(tempAngle / (Math.PI * 2) * 360);
compassContext.fillStyle = "#FFFFFF";
compassContext.fillRect(0, 0, 200, 200);
compassContext.fillStyle = "#888888";
@@ -1379,6 +1386,9 @@ function timerEvent() {
}
document.getElementById("coordinates").innerHTML = localPlayer.pos.toString();
+ var tempOffset = localPlayer.pos.copy();
+ tempOffset.subtract(respawnPos);
+ document.getElementById("respawnOffset").innerHTML = tempOffset.toString();
var tempDistance = Math.round(localPlayer.pos.getDistance(respawnPos));
document.getElementById("respawnPosDistance").innerHTML = tempDistance;
diff --git a/views/game.html b/views/game.html
index c6665f9..d66fd03 100644
--- a/views/game.html
+++ b/views/game.html
@@ -86,10 +86,13 @@
Respawn Location: <span id="respawnPos"></span>
</div>
<div style="margin-bottom: 5px;">
+ Respawn Offset: <span id="respawnOffset"></span>
+ </div>
+ <div style="margin-bottom: 5px;">
Distance to Respawn Location: <span id="respawnPosDistance"></span>
</div>
<div style="margin-bottom: 5px;">
- Direction to Respawn Location:
+ Direction to Respawn Location: <span id="respawnAngle"></span>&#176;
<br />
<canvas id="compassCanvas" width="200" height="200" style="width: 100px; height: 100px;"></id>
</div>