How We Will Test Collisions
We will employ a simple setTimeout
loop to move these objects closer and closer together. As the bounding
boxes of each collide, our code will then drop into an algorithm that
will test the alpha value on each pixel at the overlap between the
objects. If this alpha value is not 0, we know that the objects have
collided.
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.