Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Snake Game

🐍 Snake Game

A modern, interactive Snake game built with vanilla HTML, CSS, and JavaScript.
Play it directly in your browser — no dependencies, no build tools.

HTML5 CSS3 JavaScript


🎮 Gameplay

Control a snake on a grid-based board. Eat the red food pellets to grow longer and increase your score. Avoid hitting the walls or your own tail — one collision and it's game over.

Control Action
or W A S D Change direction
Space Pause / Resume
Swipe (mobile) Change direction
Tap (mobile) Unpause / Restart

✨ Features

  • Smooth rendering — interpolated movement between game ticks for fluid visuals
  • Adjustable FPS — choose 30, 60, 120, unlimited, or a custom frame rate
  • Visual effects — glow/shadows, food pulse animation, grid lines (all toggleable)
  • High score — persisted in localStorage, survives page reloads
  • Game timer — tracks how long you've survived
  • Pause overlay — pause anytime with Space or the pause button
  • Mobile friendly — responsive layout with touch/swipe support
  • Settings panel — gear icon opens a modal with all configuration options

🚀 Getting Started

Prerequisites

A modern web browser (Chrome, Firefox, Safari, Edge).

Run Locally

  1. Clone or download this repository
  2. Open index.html in your browser

That's it. No npm install, no dev server, no build step.

# Or serve with any static server:
npx serve .

📁 Project Structure

JS/
├── index.html      Entry point & HTML structure
├── style.css       All styling (dark theme, responsive, animations)
├── server.js       Game logic & rendering engine
└── README.md       This file
File Purpose
index.html Canvas, settings panel, info bar (score, timer, high score), overlays
style.css CSS custom properties, flexbox/grid layout, backdrop blur, toggle switches, mobile breakpoints
server.js Snake movement, collision detection, food generation, rendering (canvas API), FPS throttle, touch/keyboard input, localStorage persistence

⚙️ Settings

Click the ⚙ gear icon to open the settings panel:

Setting Description
Target FPS Limit render FPS to 30, 60, 120, unlimited, or custom
Glow / shadows Toggle shadow effects on snake head and food
Food pulse animation Toggle breathing animation on food
Grid lines Show/hide the subtle background grid
Show FPS counter Show/hide the FPS display in the info bar

All settings are persisted in localStorage.


📝 License

MIT — feel free to use, modify, and share.

About

This is a modern, browser‑based Snake game built with vanilla HTML, CSS, and JavaScript, optimized for smooth rendering at adjustable frame rates (30, 60, 120, unlimited, or custom).

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages