Game Object Physics and Animation
All of our game objects will move on a two-dimensional plane. We will
use basic directional movement vectors to calculate the change in the
x
and y
coordinates for each game object. At its very
basic level, we will be updating the delta x (dx
) and delta y
(dy
) of each of our game objects on
each frame to simulate movement. These dx
and dy
values will be based on the angle and direction in which we want the
object to move. All of our logical display objects will add their
respective dx
and dy
values to their x
and y
values on each frame of animation. The player ship will not use strict
dx
and dy
because it needs to be able to float and turn
independently. Let’s take a closer look at the player movement now.
Get HTML5 Canvas, 2nd Edition 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.