/**
* Animating a square.
*
*
Elie Zananiri
* CART 253, Winter 2008
*/
/* global variables */
int rectX = 0;
int rectY = 50;
int rectSize = 50;
/* built-in functions */
void setup() {
size(300, 300);
noStroke();
smooth();
}
void draw() {
background(0);
moveSquare();
drawSquare();
}
/* custom functions */
// moves the square
void moveSquare() {
if (rectX < width) {
rectX = rectX + 1;
} else {
// reset to the left of the screen
rectX = 0;
}
}
// draws the square
void drawSquare() {
fill(255, 128, 0); // orange
rect(rectX, rectY, rectSize, rectSize);
}