|
|
|
@ -108,4 +108,16 @@ |
|
|
|
|
else if(e.key=='ArrowRight') inputs.right=true; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
window.addEventListener('touchstart', e => { |
|
|
|
|
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; |
|
|
|
|
|
|
|
|
|
let inputs=currentInputs; |
|
|
|
|
if(angle>.25 && angle <.75) inputs.right=true; |
|
|
|
|
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; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
})(); |
|
|
|
|