Skip to content
This repository was archived by the owner on Mar 18, 2026. It is now read-only.

NeelayK/SnakeGame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ Snake Game

A classic Snake Game built using HTML, CSS, and JavaScript, featuring smooth movement, sound effects, and score tracking.


๐ŸŽฎ Features

  • Real-time snake movement using keyboard controls
  • ๐ŸŽ Food spawning at random positions
  • ๐Ÿ”Š Sound effects for movement, eating, and game over
  • ๐Ÿง  Collision detection (self + walls)
  • ๐Ÿ† High score saved using browser local storage
  • โšก Adjustable game speed

๐Ÿ•น๏ธ Controls

Use the arrow keys to control the snake:

  • โฌ†๏ธ Up Arrow โ†’ Move Up
  • โฌ‡๏ธ Down Arrow โ†’ Move Down
  • โฌ…๏ธ Left Arrow โ†’ Move Left
  • โžก๏ธ Right Arrow โ†’ Move Right

๐Ÿš€ How to Run

  1. Clone the repository:
git clone https://github.com/your-username/snake-game.git
  1. Open the project folder

  2. Run the game:

  • Open index.html in your browser

๐Ÿงฉ Project Structure

Snake Game/
โ”‚โ”€โ”€ index.html
โ”‚โ”€โ”€ Snake.js
โ”‚โ”€โ”€ Snake.css
โ”‚โ”€โ”€ Audio/
โ”‚   โ”œโ”€โ”€ Bite.wav
โ”‚   โ”œโ”€โ”€ Die.wav
โ”‚   โ”œโ”€โ”€ Move.wav
โ”‚   โ””โ”€โ”€ Music.wav

โš™๏ธ How It Works

  • The game loop runs using requestAnimationFrame

  • The snake position is stored as an array of coordinates

  • Each frame:

    • Movement updates based on user input
    • Collision detection is checked
    • Food consumption increases score and length
  • High score is stored in localStorage


๐ŸŽฏ Gameplay Logic Highlights

  • Snake grows when it eats food
  • Game resets on collision
  • Speed controls how fast the game updates
  • Food appears randomly within the grid

๐Ÿ› ๏ธ Tech Used

  • HTML5
  • CSS3 (Grid-based layout)
  • JavaScript (Game logic & DOM manipulation)

โญ If you like this project, consider starring the repo!

About

A clock made using HTML, CSS and Js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors