Chapter 16. Making a Snake Game: Part 1

In this chapter and the next, we’ll build our own version of the classic arcade game Snake. In Snake, the player uses the keyboard to control a snake by directing its movement up, down, left, or right. As the snake moves around the playing area, apples appear. When the snake reaches an apple, it eats the apple and grows longer. But if the snake hits a wall or runs into part of its own body, the game is over.

As you create this game, you’ll combine many of the tools and techniques you’ve learned so far, including jQuery and the canvas as well as animation and interactivity. In this chapter, we’ll look at the general structure of the game and go through the code for drawing the border and the score ...

Get JavaScript for Kids now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.