Collision Detection



Try these challenge prompts to modify the code we've written. Don't get frustrated if you can't figure them all out — some are intended for more experienced programmers:

  1. Try changing the colors of the objects when they collide. Hint: look in the draw() section for the fill() command.
  2. Can you make something else interesting happen when collision occurs? Objects change size, move across the screen, etc?
  3. Our Point/Point collision is very finicky: you have to be in the exact location of the other point for the collision to trigger. Can you modify the code to include a "buffer zone" where collision happens, even if the two points aren't actually touching?

NEXT: Point/Rectangle