Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- document.getElementById("resetButton").addEventListener("click", resetGame);
- // Add this reset function
- function resetGame() {
- snake = [];
- snake[0] = { x: 10 * box, y: 10 * box };
- food = {
- x: Math.floor(Math.random() * 20) * box,
- y: Math.floor(Math.random() * 20) * box
- };
- d = null;
- score = 0;
- clearInterval(game);
- game = setInterval(draw, 100);
- }
Advertisement
Add Comment
Please, Sign In to add comment