Please enable JavaScript to use CodeHS

Snake Game

In this project, students will create their very own game of Snake, where players try to keep their ever-growing snake alive!

Hard

10 Hours

High School

Project Description

Background

The classic snake game was once played on early cell phones and computers. The game involves a snake that continuously moves forward on the screen. In some versions, the snake can’t collide into the walls of the game’s boundaries and its own body. Players can change the snake’s direction to the left or right from its current direction.


As the snake moves around on the screen, the player must also collect apples or objects that add to the snake’s length. The object of the game is to see how long the player can avoid colliding the snake with its own body and sometimes the boundaries of the game world while getting points for each item collected.


Your Task

Your goal in this project is to create a really fun snake game. Using JavaScript, you’ll create the snake game object. Then you’ll develop a system that detects if the snake collides with itself. You’ll add food or items for the snake to collect as the player moves the snake around the screen.


Your snake game will allow the player’s snake to pass through the game world’s boundaries. You’ll develop a system that lets the snake reappear at the opposite side of the game world if it passes through any given boundary side. For example, if the snake moves through the right wall, it’ll re-enter the game world from the left wall.

Project Demo

Explore this program before assigning it!

Project Overview

Here is an outline of the project activities: