Animation
Lets recap the most important issues regarding variables.
float number = 100; // create new variable called float and set its value as 100
number = 40; // set the value as 40
number = 40/2; // set the value as 40/2, which is 20
number = number + 2; // set the value as number + 2 which is 20 + 2 which is 22
number = number * 2; // set the value as number * 2 which is 22 * 2 which is 44
What’s the difference between this program…
float x = 0;
void setup() {
size(400,400);
}
void draw() {
ellipse(x, height/2, 50, 50);
x = x + 1;
}
…and this?
void setup() {
size(400,400);
}
void draw() {
float x = 0;
ellipse(x, height/2, 50, 50);
x = x + 1;
}