1
To move the tail in this game https://leonardovita.github.io/javascript-snake-game/ using the touch screen of the mobile phone, need to calculate the position of the click on the screen, as in the example of the image below, only one direction can be received
or any other native javascript solution more efficient than to move the cover with touch
const screenWidth = window.screen.width;
const screenHeight = window.screen.height;
document.addEventListener("click",handleClickTouchPad)
function handleClickTouchPad(event){
//calcula o X e o Y para determinar qual triangulo da imagem abaixo foi o click
if(up === true ){
//move para cima
}
else if ( right === true){
//move para direita
}else
...
}
Interesting guy your solution, pretty cool to work with the touch so, but the game of the cover needs more speed if not the player loses, play dragging your finger and very slow, the right same would only be in the touches
– leonardo vita
Valew man, I tried to adjust according to what you reported to me, so I edited my solution and I think now can help you.
– Lucas Pinafi