ellipse() that follows your mouse.ellipse(), add this line:if (mouseX > 100) {
text("what just happened?", 200, 200)
}
What happened? Why do you think that’s happening?
Conditionals in p5 work exactly like JavaScript conditionals. Thanks to our built-in variables, we can quickly make sketches that change depending on where our mouse is.
ellipse(), rect(), etc) that follows your mousefill() of the shape changes if the mouse is on the left or right side of the screen.Like this:
Create this “traffic light” in p5:
Rubric
| Specification | Points |
|---|---|
| 3 ellipses, each light up different colors | 3 |
| It must be able to “light” up in three different colors one at a time | 1 |
| Only one light should be lit at a time | 1 |
| Lights are conditionally activated[^1] | 1 |
| Total | 6 |