Detecting Collisions

Let's add collision detection and destruction mechanics to our game and see the game in action.

Collision detection

This game won’t be any fun if there’s no element of danger. Let’s open up collisions.ts and take a look around. I’ve filled in the math stuff that isn’t as relevant to the Rx core. There’s a checkCollision function that operates much like the other updates you’ve seen. This one’s filled out since it’s more of the same that you’ve already written.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy