© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2023
J. MeyerThe Essential Guide to HTML5https://doi.org/10.1007/978-1-4842-8722-4_4

4. Cannonball and Slingshot

Jeanine Meyer1  
(1)
Purchase, NY, USA
 
In this chapter, we cover the following:
  • Maintaining a list of objects to draw on the screen

  • Rotating objects drawn on the screen

  • Mouse drag-and-drop operations

  • Calculations to simulate ballistic motion (effects of gravity) and collisions

Introduction

This chapter demonstrates another example of animation , in this case simulation of ballistics, also called projectile motion . A ball or ball-like object maintains a constant horizontal (x) displacement, with the vertical displacement changing as it would due to gravity. ...

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.