addedd speed modifyer

This commit is contained in:
Maxim Stewart 2020-06-28 22:40:19 -05:00
parent 93190587a6
commit b53db698a6
3 changed files with 38 additions and 13 deletions

View File

@ -43,6 +43,12 @@ input {
z-index: -999; z-index: -999;
} }
#canvas {
position: relative;
width: 98%;
min-height: 800px;
}
#singleClickBtn, #doubleClickBtn { #singleClickBtn, #doubleClickBtn {
background-color: #62c462; background-color: #62c462;
border-style: dashed; border-style: dashed;

View File

@ -1,6 +1,8 @@
const socket = io(); const socket = io();
let intervalTimer = null;
let px = 0; let px = 0;
let py = 0; let py = 0;
let mod = 1;
socket.on('connect', function() { socket.on('connect', function() {
@ -13,28 +15,28 @@ $(function () {
$("#canvas").on("mousedirection", function (e) { $("#canvas").on("mousedirection", function (e) {
if (e.direction == "up") { if (e.direction == "up") {
px = 0; px = 0;
py = -1; py = -1 - mod;
} else if (e.direction == "down") { } else if (e.direction == "down") {
px = 0; px = 0;
py = 1; py = 1 + mod;
} else if (e.direction == "left") { } else if (e.direction == "left") {
px = -1; px = -1 - mod;
py = 0; py = 0;
} else if (e.direction == "right") { } else if (e.direction == "right") {
px = 1; px = 1 + mod;
py = 0; py = 0;
} else if (e.direction == "top-left") { } else if (e.direction == "top-left") {
px = -1; px = -1 - mod;
py = -1; py = -1 - mod;
} else if (e.direction == "top-right") { } else if (e.direction == "top-right") {
px = 1; px = 1 + mod;
py = -1; py = -1 - mod;
} else if (e.direction == "bottom-left") { } else if (e.direction == "bottom-left") {
px = -1; px = -1 - mod;
py = 1; py = 1 + mod;
} else if (e.direction == "bottom-right") { } else if (e.direction == "bottom-right") {
px = 1; px = 1 + mod;
py = 1; py = 1 + mod;
} }
updateText (px, py); updateText (px, py);
@ -73,6 +75,23 @@ function touchHandler(event) {
event.preventDefault(); event.preventDefault();
} }
function beginTimerModBump() {
intervalTimer = setInterval(function () {
mod += 1;
}, 800);
}
function endTimerModBump() {
clearInterval(intervalTimer);
mod = 1;
}
document.addEventListener("mousedown", beginTimerModBump, true);
document.addEventListener("mouseup", endTimerModBump, true);
document.addEventListener("touchstart", touchHandler, true); document.addEventListener("touchstart", touchHandler, true);
document.addEventListener("touchmove", touchHandler, true); document.addEventListener("touchmove", touchHandler, true);
document.addEventListener("touchend", touchHandler, true); document.addEventListener("touchend", touchHandler, true);

View File

@ -27,7 +27,7 @@
X coords: 0, Y coords: 0 X coords: 0, Y coords: 0
</div> </div>
<canvas id="canvas" width="650" height="650" style="border:1px solid #c3c3c3;"></canvas> <canvas id="canvas" style="border:1px solid #c3c3c3;"></canvas>
</div> </div>
</div> </div>
</div> </div>