© Jeanine Meyer 2018
Jeanine MeyerThe Essential Guide to HTML5https://doi.org/10.1007/978-1-4842-4155-4_3

3. Bouncing Ball

Jeanine Meyer1 
(1)
Purchase, NY, USA
 
In this chapter, we cover
  • Creating programmer-defined objects

  • Using setInterval for animation

  • Drawing images

  • Accepting and validating form input

  • Using buttons

  • Using for loops

  • Drawing with gradients

  • Preloading images

Introduction

Animation, whether at the movies, using a flipbook, or generated by computer, involves displaying a sequence of still images fast enough so that we interpret what we see as movement, as life. In this chapter, I’ll show you how to produce animated scenes by simulating a ball bouncing in a two-dimensional box, with horizontal and vertical speeds that can by changed by a player. ...

Get The Essential Guide to HTML5: Using Games to Learn HTML5 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.