// Practice with arrays // myArray is an array of 20 ints //int [] myArray = new int[20]; // Set a value using square brackets //myArray[5] = 12; //println(myArray[3]); // Create arrays to hold shape values int [] xCoords = {25, 30, 100, 317, 208}; int [] yCoords = {25, 150, 210, 102, 200}; int [] heights = {15, 50, 100, 25, 35}; int [] widths = {5, 10, 10, 5, 35}; void setup () { size(400, 300); background(20); fill(150, 240, 100); frameRate(10); // Slow down display } void draw () { background(20); // clear screen for (int i = 0; i < xCoords.length; i = i + 1) { rect(xCoords[i], yCoords[i], widths[i], heights[i]); // Pick value between 0 and 20 // - # = move left, + # = move right int xMoveAmount = (int)(random(50)) - 25; int yMoveAmount = (int)(random(50)) - 25; int heightChange = (int)(random(50)) - 25; int widthChange = (int)(random(50)) - 25; xCoords[i] = xCoords[i] + xMoveAmount; yCoords[i] = yCoords[i] + yMoveAmount; heights[i] = heights[i] + heightChange; widths[i] = widths[i] + widthChange; } }