Lab 05
Lab 05 · Crazy ball
Notes
What I added
-
runFromMouse(byHowMuch): when the mouse is closer than 80 pixels, the ball is pushed away from it. The push depends on how far the ball is from the mouse,so a ball farther from the center gets pushed harder. -
glowNearMouse(range): when the mouse is closer thanrangepixels, the ball changes color, and it goes back to its own color when the mouse leaves.this.startColorremembers the color it started with. -
Both methods live inside the
Ballclass and are called fromchange()beforeshow(), so they run for every ball, every frame.
Bonus
-
A new glow color every 10 seconds: every 600 frames,
draw()picks a randomglowColor, and all the balls near the mouse use it. -
Click to leave a cat:
mousePressed()saves each click incatXandcatY. The cats are drawn before the balls, so the balls move over them.
The git repo: Lab05