So i have something similar to snake game ( with just head) but when ever i press button call function change direction ( left, right ....) it keep going faster.I think it because setimeout but i dont know where to put cleartimeout can you guy help me ?
function automove() {
Snake[1] = snake[1] + y;
Snake[0] = snake[0] + x;
}
function left() {
x = -5;
y = 0;
if( i = 1) {
start();
}};
function start() {
gamerun = true;
drawotobody();
nextmove();
};
function nextmove() {
if(gamerun = true){
setTimeout(()=>{
contactborder();
clearboard();
drawotobody();
automove();
nextmove();
}, 75);}
};