SECTION 3
CHALLENGES
Try these challenge prompts to modify the code we've written:
- Lasers! Can you build a simple game where the player uses the mouse to navigate an array of lasers and get to the other side of a room? Draw your character as a simple circle or rectangle, or replace them with an image but test the collision as a bounding circle or box.
- Using Line/Circle collision, we can simulate a ball bouncing off an angled surface. Can you add gravity, plus make the circle bounce off in a direction based on the angle of the line? Hint: to get the bounce direction, get the angle between the ball and the closest point on the line. For this, you can use Processing's
angleBetween()
function.