Games

Build a Snake Game with AI

Recreate the beloved classic snake game using HTML5 canvas with a retro pixel aesthetic, smooth grid-based movement, arrow key and WASD controls, mobile touch support, increasing speed as you eat, collision detection against walls and yourself, and persistent high score tracking.

Build Prompt

Copy this prompt into Claude Code
Build a single-page snake game as a static HTML/CSS/JS site using HTML5 Canvas. Use a dark retro theme with page background #0f0f17 and the game canvas background #0a1a0a (very dark green). Center the canvas on the page with a header showing the score, high score, and current speed level. The game canvas should be 400x400 pixels on desktop (scaling down on mobile) with a 20x20 grid (each cell is 20px). Draw faint grid lines (#0d2a0d) so the retro grid is visible. The snake is bright green (#22c55e) with the head being a slightly different shade (#16a34a) and small pixel eyes (2px white dots) facing the direction of movement. Each body segment should have a 1px darker border to distinguish segments. The food is a red (#ef4444) square with a subtle pulsing glow animation. Movement: the snake moves on a grid, one cell per tick. Support arrow keys and WASD for directional input. Prevent 180-degree reversals (if moving right, pressing left is ignored). Queue directional inputs so that rapid key presses register correctly between ticks. The initial tick speed is 150ms, decreasing by 5ms every time food is eaten (minimum 60ms). Display the current speed level (Level 1 at 150ms, Level 2 at 145ms, etc.) in the header. Food spawning: when food is eaten, spawn a new food item at a random empty cell (not on the snake body). The snake grows by one segment. Award 10 points per food item, plus a bonus of (current level * 5). Every 5th food item spawns a special golden food (#eab308) that is worth 50 points but disappears after 5 seconds if not eaten — show a countdown ring around it. Collision detection: the game ends if the snake head collides with any wall boundary or with its own body. On game over, flash the screen briefly (red overlay fading out), show a "Game Over" modal with the final score, length achieved, top speed level reached, and time survived. If it's a new high score, show a celebration message and a pulsing glow effect. Display a "Play Again" button and a "Menu" button. Implement a start menu with the game title in a retro pixel font (use CSS with letter-spacing), a "Start Game" button, difficulty selection (Slow at 200ms starting speed, Normal at 150ms, Fast at 100ms), a wall toggle (walls on = classic, walls off = snake wraps around to the opposite side), and a high scores table showing top 5 scores per difficulty from localStorage. Pause functionality: pressing spacebar pauses and unpauses the game, showing a semi-transparent overlay with "PAUSED" text and controls reminder. Also pause when the browser tab loses focus. Mobile touch controls: detect swipe direction on the canvas area (minimum 30px swipe distance). Also display four semi-transparent directional arrow buttons below the canvas on touch devices (detected via media query or touch event support). The buttons should be arranged in a D-pad layout (up, down, left, right) and have active-state feedback. Add optional retro sound effects using Web Audio API: a short blip when eating food, a deeper tone for golden food, and a descending tone sequence on game over. Include a mute toggle button (speaker icon) in the header that persists in localStorage. Read the guide at https://accessagent.ai/api/guide and follow it to deploy the site to AccessAgent.ai. My email is [your@email.com].

Make It Yours

Snake Skins

Add unlockable snake skins based on high scores: rainbow gradient at 500 points, neon blue at 1000, fire pattern at 2000. Store unlocks in localStorage.

Obstacle Mode

Add randomly placed wall blocks inside the game grid that the snake must navigate around. Increase obstacles with each level for added challenge.

Two-Player Mode

Split the canvas and run two snakes simultaneously — Player 1 on WASD, Player 2 on arrows. First to crash loses. Shared food items.

Power-Ups

Spawn random power-ups: speed boost (temporary 2x speed), slow motion (halves speed for 5 seconds), shrink (removes 3 segments safely).

SEO Tips

Monetization Ideas

Related Ideas

Ready to build your Snake Game?

Copy the prompt above and paste it into Claude Code. Your retro snake game will be live in minutes.

Get Started