//******************************************* //Declare a Variable to remember the y coordinate of // the blue rectangle //******************************************* float y_Blue_Rect = 0; //******************************************* //Declare a Variable to remember the diretion of movement // for the blue rectangle //******************************************* float directionMoveBlue = 5; //******************************************* //The function that defines the initial set up //******************************************* void setup() { size(600, 600); stroke(255); } //******************************************* //The function that is repeatedly called to // draw things and interact with the user //******************************************* void draw() { background(192, 64, 0); //A red rectangle to follow the mouse fill(255, 0, 0); rect(mouseX, mouseY, 50, 50); //A blue rectangle to move up and down fill(0, 0, 255); rect(0, y_Blue_Rect, 100, 50); y_Blue_Rect = y_Blue_Rect + directionMoveBlue; if (y_Blue_Rect > 600) directionMoveBlue = -5 ; if (y_Blue_Rect < 0) directionMoveBlue = +5 ; }