Snake game built using Javascipt and HTML
Run with live server to run SnakeGame
Open HTML file and right click on the editor on Open with Live Server.
let d;
document.addEventListener("keydown",direction);
function direction(event){
let key = event.keyCode;
if( key == 37 && d != "RIGHT"){
left.play();
d = "LEFT";
}else if(key == 38 && d != "DOWN"){
d = "UP";
up.play();
}else if(key == 39 && d != "LEFT"){
d = "RIGHT";
right.play();
}else if(key == 40 && d != "UP"){
d = "DOWN";
down.play();
}
}
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.