Skip to main content
  • 1694 Accesses

Abstract

In this chapter, you learned how to

  • declare variables and use global variables to represent application state

  • write code to perform arithmetic operations

  • define and use programmer-defined functions

  • use several built-in features of JavaScript, including the Math.random and Math.floor methods

  • use if and switch statements

  • create a canvas using an HTML element

  • draw rectangles and circles

This chapter introduced a key feature of HTML5, the canvas, as well as the notions of randomness and interactivity. It also presented many programming features you’ll use in the examples in the rest of the book. In particular, the technique of building an application in stages is useful. The next chapter will feature the animation of a ball bouncing in a box—preparation for the real games in Chapter 4: the ballistics simulations called cannon ball and sling shot.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 34.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2010 by Jeanine Meyer

About this chapter

Cite this chapter

Meyer, J. (2010). Dice Game. In: The Essential Guide to HTML5. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4302-3384-8_2

Download citation

Publish with us

Policies and ethics