O'Reilly logo

HTML5 Game Development HOTSHOT by Makzan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling collision detection

In this task, we detect if the ball passes through the hoop and we reward the player with scores. We will also create a world boundary and remove balls that are out of bounds.

Prepare for lift off

The detection is done by placing a sensor between the hoop squares. The following figure shows how the sensor is placed:

Prepare for lift off

For the boundary, it will be a long body that is placed at the bottom of the world, as shown in the following figure:

Prepare for lift off

Engage thrusters

Let's add the sensor and handle the collision in the following steps:

  1. First, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required