Snake game

Hard
·
150 minutes

Prompt

Create a Snake game (example) that meets the following requirements:

  • 15x15 grid
  • Snake should be controlled with cursor keys (or WASD if you prefer)
  • Snake should start with a length of 3
  • One apple at a time should appear in a random position on the grid. When collected, it should increase the score by one, increase the snake length by one, and change to another random position
  • Display a score for how many apples have been collected
  • If the snake head collides with the rest of the body, the game should end
  • If the snake head collides with the borders, the game should end

Submitting solutions

  1. Create a solution by forking one of our CodePen templates:
  2. Submit your solution here

Hints

Additional challenges

Get future questions delivered straight to your inbox for free

Sign up and receive instant access to new questions when we publish them.

We‘ll only use your information to deliver new questions and to provide you updates about our product. We‘ll never spam you or sell your information without your consent. Unsubscribe at any time.