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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Rights 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
DOI: https://doi.org/10.1007/978-1-4302-3384-8_2
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4302-3383-1
Online ISBN: 978-1-4302-3384-8
eBook Packages: Professional and Applied ComputingProfessional and Applied Computing (R0)Apress Access Books