Skip to Content
JavaScript for Kids
book

JavaScript for Kids

by Nick Morgan
December 2014
Beginner
336 pages
6h 32m
English
No Starch Press
Content preview from JavaScript for Kids

Chapter 17. Making a Snake Game: Part 2

In this chapter, we’ll finish building our Snake game. In Chapter 16, we set up the playing area and covered how the game would work in general. Now we’ll create the objects that represent the snake and apple in the game, and we’ll program a keyboard event handler so that the player can control the snake with the arrow keys. Finally, we’ll look at the complete code listing for the program.

As we create the snake and apple objects for this game, we’ll use the object-oriented programming techniques we learned in Chapter 12 to create constructors and methods for each object. Both our snake and apple objects will rely on a more basic block object, which we’ll use to represent one block on the game board grid. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

JavaScript For Kids For Dummies

JavaScript For Kids For Dummies

Chris Minnick, Eva Holland
JavaScript Projects for Kids

JavaScript Projects for Kids

Syed Omar Faruk Towaha

Publisher Resources

ISBN: 9781457189838Errata Page