Chapter 3

Creating the First Game

The goal of this chapter is to make a simple 2D web game. We have already learned the essentials of the canvas API, the powerful mechanism for rendering arbitrary shapes or images inside the web page. Now it is time to use this knowledge in practice and create a real game project.

We will call our game “Four Balls.” This is the web version of the popular logical game that has been known under several names, including “Four in a Row,” “Four in a Line,” and “Plot Four,” and has had several rule variations. According to rumors, the game was played as early as 18th century by Captain James Cook. He loved the game so much, that his crew called it “The Captain’s Mistress.” A popular commercial version of the game, ...

Get Pro Android Web Game Apps: Using HTML5, CSS3 and JavaScript 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.