How to Code: Collision Detection — Part I

June 6th 2017 | 37.3k views

Collision detection is what tells us when two objects have touched. By reacting to collisions, we can increase a user's score within an HTML5 canvas game, change objects' colors only when they have touched, and even determine when a user's character should take damage.

Part I of this series will cover how to implement collision detection between just two objects, while part II will cover how to code collision detection between multiple objects.

Programming collision detection may seem scary at first, but it becomes exponentially easier with a basic understanding of some rudimentary math. Learn how to code this reactive effect in the latest installment of How to Code.