|
|
|
@ -90,11 +90,10 @@ |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
currentGame=snek; |
|
|
|
|
//XXX
|
|
|
|
|
window.snek=snek; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
window.addEventListener('keydown', async e => { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
if(e.key=='f') { |
|
|
|
|
if(document.fullscreenElement) await document.exitFullscreen(); |
|
|
|
|
else await main.requestFullscreen(); |
|
|
|
@ -108,7 +107,8 @@ |
|
|
|
|
else if(e.key=='ArrowRight') inputs.right=true; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
window.addEventListener('touchstart', e => { |
|
|
|
|
const handleTouch=e => { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
let x=e.touches[0].clientX/window.innerWidth-.5; |
|
|
|
|
let y=e.touches[0].clientY/window.innerHeight-.5; |
|
|
|
|
const angle=((Math.atan2(x, y)+2*Math.PI)%(2*Math.PI))/Math.PI; |
|
|
|
@ -118,6 +118,10 @@ |
|
|
|
|
else if(angle>.75 && angle<1.25) inputs.up=true; |
|
|
|
|
else if(angle>1.25 && angle<1.75) inputs.left=true; |
|
|
|
|
else inputs.down=true; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
inputs.clearBuffer=true; |
|
|
|
|
}; |
|
|
|
|
window.addEventListener('touchstart', handleTouch); |
|
|
|
|
window.addEventListener('touchmove', handleTouch); |
|
|
|
|
|
|
|
|
|
})(); |
|
|
|
|