Figure 22—The game controller communicates with a Chrome app.
Creating the Game
At this point you know enough about Chrome apps and controlling a motion-
sensing game controller to create an entertaining video game. Writing a video
game isn’t directly related to programming the Arduino. Still, it’ll show you
some techniques you can use in other projects, and it’ll give you a much
better understanding of how the integration of hardware and software works.
Before you dive into the code, download it from the book’s website
2
and play
the game. Doing so will help you find your way through the code much easier.
When programming a browser game, you usually start with its HTML code.
In our case it looks like this:
BrowserGame/Arduinoid/main.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="css/arduinoid.css"/>
<title>Arduinoid</title>
2.
http://www.pragprog.com/titles/msard2
Chapter 7. Writing a Game for the Motion-Sensing Game Controller • 114
report erratum • discuss
www.it-ebooks.info