Learn creative coding writing simple programs

12. Do a loop animation using an if() statement

In this episode we learn how we can use the if() statement to execute some code conditionally. That means the code is not executed always, but only if certain condition is met. In our example, the condition is that the circle has moved too far to the right. In that case, we bring the circle back to the left border of the screen.
We also see how to animate two objects at different speeds, and how each object can have a different color.

Tags: loop, conditional, if

Code editor

You can make changes to the code below. Then
Questions and comments are welcome! :) But please try to stay close to the topic of this episode. Use the Processing forums for help with your Processing projects (or hire me for help ;-)