This is a simple implementation of the classic Snake game using JavaScript.
- The game includes a scoring system, with a current score and high score. 🏆
- The game ends if the snake collides with the wall or with itself, and a message is displayed indicating the reason for the game over. 🚫
- The game is won if the snake fills up the entire canvas. 🎉
- The snake cannot move in the opposite direction to its current direction. 🔄
- Make sure to have Node.js installed. 🚀
- Clone or download the repository. 💻
- Make sure to have the project dependencies installed by running the following command
npm install express ejs
📦 - Navigate to the project directory. 📂
- Open command prompt. 💻
- Run the following command
node index.js
🌐 - And have fun playing the game! 🎮
- Use the arrow keys or 'w', 'a', 's', 'd' keys to control the snake. ⌨
- Click on the canvas to start the game. 🖱
- Sadly there is no pause button. 😢
- Refresh the page to restart the game. 🔄
- And the high score doesn't save. 😢
public/javascript/index.js
: This is the main game file. It sets up the game and contains the game loop. 🎮public/modules/snakeLogic.js
: This file contains theSnake
class, which handles the snake's movement and collision checks. 🐍public/modules/canvasLogic.js
: This file contains theCanvas
class, which handles drawing on the canvas and displaying game over and game won messages. 🖼public/modules/appleLogic.js
: This file contains theApple
class, which handles the apple's position. 🍎public/modules/scoreLogic.js
: This file contains theScore
class, which handles the game's scoring system. 🏆
Enjoy the game! 🎉
- Jeremiah J.
- Google snake