Skip to content

Casual Implementation of classic snake and apple game using Vanilla JavaScript with simple and minimal UI

License

Notifications You must be signed in to change notification settings

heissanjay/Snake-Game-JS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Snake Game JS 🐍

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.

Features

  • 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.

How to Play

  1. Open the game in a web browser that supports JavaScript.
  2. Use the arrow keys to control the direction of the snake.
  3. Guide the snake to eat the apples that appear on the game area.
  4. As the snake eats an apple, it will grow longer, and your score will increase.
  5. Avoid colliding with the snake's own body or the boundaries of the game area.
  6. The game ends when the snake collides, and you can restart it by pressing a key.

Technologies Used

  • HTML
  • CSS
  • JavaScript

Preview

Video

Installation

No installation is required. Simply open the game in a web browser.

License

This project is licensed under the MIT License.

About

Casual Implementation of classic snake and apple game using Vanilla JavaScript with simple and minimal UI

Topics

Resources

License

Stars

Watchers

Forks