Lesson 6: Detecting Collisions

This video will likely be best viewed in fullscreen mode.  It's about 8 minutes long.  You can download the resulting file below.

In this lesson, we introduce collision detection - we want to know when two of our rectangles overlap, whether they're the laser and an enemy or an enemy and our hero.  We write a simple rectangular intersection function in JavaScript.  We then use this function to determine if any of our enemies have been hit by the laser or if our hero has been hit by any of the enemies.  We also check to see if our enemies have traveled to the bottom of the screen.

Timothy James,
Jul 20, 2015, 6:57 PM