there is the example http://luislalo.com/game/
get the tabs direction
function getDirection(){
let direction
if((margenIzquierdo()==-39.2 && ((((margenArriba()*10)%(-19.6*10))/10)==0))
|| (margenIzquierdo()==0 && ((((margenArriba()*10)%(-19.6*10))/10)!=0))){
direction = 'up'
}
else if((((margenArriba()*10)%(-19.6*10))/10)==0){
direction = 'left'
}else{
direction = 'right'
}
return direction
}
I think the problem is here where i check the win and check the range, but i don't know why
function checarVictoria(){
if(margenArriba()==-39 && margenIzquierdo()==0){
document.querySelector('#p_turno').innerHTML = `${turno} ¡Player wins!`
new Audio('win.mp3').play()
return turno
}
else{
return 'none'
}
}
check the range
function checarRango(dadoNum){
let fueraDeRango = false
if(margenArriba()==-39.2 && (margenIzquierdo()+Number((dadoNum*-9.8).toFixed(1)))<0){
fueraDeRango = true
}
return fueraDeRango
}