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.
Code editor
You can make changes to the code below. Then
Try to stay close to the topic of this episode. Use the Processing forums for help with unrelated Processing projects (or hire me for help ;-)
To indicate that a word in your comment is code, use the `backtick`. Example
Do `float` and `int` smell similar?
To highlight code blocks, surround it with ``` code-fences ``` like this:``` void setup() { size(600, 600); } ```