Challenge Overview
Medium
Let's add the ability to eat food for the snake. Let's also add a feature to change game board size, and to reset the game.
- Number the positions of the board from left-to-right and up-to-down. For example, the first row has elements 0,1,2,3,4 and so on.
- For each number that is a prime, set a "+" character to mark it as food.
- When the snake moves into a square with food, it eats the food and gains one point
- In a div called "scoreContainer", print the score as follows
Score: 0
- Points are initially 0. When the snake eats a food, the score increases by 1.
- Add an input of type text with id boardSize
- Add an input of type button with text value "Set game size! (5-30)" and id "setSize"
- Add an input of type button with id "resetGame" and text value "Reset game!"
- When the user writes a number between 5 and 30, inclusive, and presses the setSize button -> the game board will change to that size. A previous game is also reset by changing the size.
- When the user presses the resetGame button, the game is reset without changing size.
- The snake's starting position is always in the middle, rounded down. Precisely it is floor(boardSide/2) for both coordinates.
The game should reset when refreshing the page.
CHANGELOG: fixed floor(boardSide/2)