O'Reilly logo

The Essential Guide to HTML5: Using Games to Learn HTML5 and JavaScript by Jeanine Meyer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. Rock, Paper, Scissors

Rock, Paper, Scissors
  • playing against a computer

  • creating graphics to serve as buttons

  • arrays of arrays for game rules

  • the font-family property

  • inherited style settings

  • audio

Introduction

This chapter combines programming techniques with HTML5 JavaScript features to implement the familiar rock-paper-scissors game. In the school yard version of this game, each player uses hand symbols to indicate one of the three possibilities: rock, paper, or scissors. The terminology is that a player throws one of the three options. The game rules are stated this way:

  • Rock crushes scissors.

  • Paper covers rock.

  • Scissors cuts paper.

So each symbol beats one other ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required