Skip to content

meenaviyal/snake

Repository files navigation

Snake Game

Overview

This project is a simple, classic Snake game implemented using HTML5, CSS3, and JavaScript. The player controls a green snake that moves around the screen, attempting to eat red food to grow longer. The game ends when the snake collides with itself or the edges of the game area. The goal is to achieve the highest score possible.

The game features:

  • A vibrant green snake (#4ade80) for a modern look.
  • A simple, intuitive interface, accessible on both desktop and mobile devices.
  • Mobile controls for easy gameplay on touch devices.
  • Smooth animations and responsive performance.
  • Score tracking with both current and high scores.

How to Play

  1. Use the arrow keys on your keyboard or the mobile buttons (on touchscreen devices) to control the direction of the snake.
  2. Eat the red food to grow longer.
  3. Avoid colliding with the snake's body or the edges of the screen.
  4. Try to achieve the highest score before the snake dies.

Files

  • index.html: Contains the HTML structure of the game, including the canvas for rendering the game and mobile controls for touch devices.
  • styles.css: Provides styling for the game layout, colors, fonts, and responsiveness.
  • script.js: Contains the JavaScript logic for the game, including the snake's movement, collision detection, and score tracking.

License

This project is licensed under the MIT License. See the LICENSE file for more details.