This is a simple implementation of the classic Snake game using JavaScript. The objective of the game is to control the snake and guide it to eat apples, which makes the snake grow longer. The game continues until the snake collides with itself or with the boundaries of the game area.
- Controls: Use the arrow keys on your keyboard to control the snake's direction—up, down, left, or right.
- Score: Each time the snake eats an apple, your score increases by one point.
- Speed: the speed value remains constant for the entire game you can tweak the speed in the
gameloop()
function in the src code. (currently the game speed is 15 FPS) - Collision Detection: The game automatically detects if the snake collides with itself or the boundaries, resulting in a game over.
- Restart: Once the game is over, you can restart it by pressing a key.
- Open the game in a web browser that supports JavaScript.
- Use the arrow keys to control the direction of the snake.
- Guide the snake to eat the apples that appear on the game area.
- As the snake eats an apple, it will grow longer, and your score will increase.
- Avoid colliding with the snake's own body or the boundaries of the game area.
- The game ends when the snake collides, and you can restart it by pressing a key.
- HTML
- CSS
- JavaScript
No installation is required. Simply open the game in a web browser.
This project is licensed under the MIT License.