Loops are the main way of iterating over code. There are various types of loops, but the most complex (and possibly the most useful) is the 'for' loop construct.
for ( int i = 0; i < 10; i++) {Embedded for loops allow us to iterate over two dimensions of information
// do something with variable 'i'
}
for (int x = 0; x < 10; x++) {For more examples, see:http://www.processing.org/learning/basics/iteration.htmlhttp://www.processing.org/learning/basics/embeddediteration.htmlIn Processing, we are used to calling functions, such as line(), size(), draw(). We will start experimenting with writing our own functions today. Design a character (on paper) that will respond to the mouse clicking and movement. The simplest place to start will be the eyes. Plan on having the eyes respond to the mouseX and mouseY, and maybe have the character blink when you click the mouse button. Be sure to use variables in your character design, and we will explore how to parametrize our character function on Wednesday. Character template:
for (int y = 0; y < 10; y++) {
// do something with x and y
}
}
void setup() {
size(640, 480);
}
void draw() {
background(255);
myCharacter(); // draw your character
}
void myCharacter() {
// draw character here
}