Add touch events

master
sigonasr2 4 years ago
parent 6bbac9e8d5
commit d328b6d02c
  1. 11
      game.js

@ -301,9 +301,19 @@ function setupGame() {
document.getElementById("game").appendChild(canvas)
canvas.addEventListener("mousemove",updateMouse)
canvas.addEventListener("touchmove",updateMouse)
canvas.addEventListener("touchstart",clickEvent)
canvas.addEventListener("touchend",releaseEvent)
//gameGrid = [...createGrid(5,5)]
}
function clickEvent(e) {
console.log("Click")
}
function releaseEvent(e) {
console.log("Release")
}
function loadLevel(level,botx,boty) {
placeBot(botx,boty)
gameGrid = deepCopy(level)
@ -335,6 +345,7 @@ function step() {
function updateMouse(e) {
//console.log(getMousePos(canvas,e))
e.preventDefault()
console.log("Move")
var mousepos = getMousePos(canvas,e)
LAST_MOUSE_X=mousepos.x
LAST_MOUSE_Y=mousepos.y

Loading…
Cancel
Save