Science Leadership Academy

Learn • Create • Lead

Computer Science Engineering - Advanced - Alfano

Create a post

Public Feed

HTML5 canvas sandbox v3 - Multiple objects

Posted by Chris Alfano in CSE-003 on

We now use an array to store a list of circles so that we can track more than one. Each item in the array is an object containing x, y, dx, dy, and r for one circle

The script listens for the space bar to add circles to the system (click inside the red box first so it will hear you)

Be the first to comment

UPDATED: HTML5 bouncing ball example

Posted by Chris Alfano in CSE-003 on

This new version of the example features better comments explaining each line of code.

It also includes the changes we made in class today to create a variable (radius or r) that holds the ball's radius and is used to make the ball bounce before any of its edges goes off any side of the canvas. (notice in the previous example that the ball doesn't bounce until its center reaches an edge)

Be the first to comment