float c = random(255); int count = 4; float[] posX = new float[count]; float[] posY = new float[count]; float[] speedX = new float[count]; float[] speedY = new float[count]; float[] sizeW = new float[count]; float[] sizeH = new float[count]; int[] colors = new int[count]; //String[] strA = new String[count]; String[] strA = {"Zack", "Trevor", "Lisa", "Chris"}; //String is from words. These arrays label the random shapes that are flying arround the screen int[] shapez = new int[count]; //Shapez is an array that changes or randomises the type of shape that is spawned void setup() { size(600, 600); for (int i=0; i < posX.length; i++) { posX[i] = width/2; posY[i] = height/2; speedX[i] = random(-10, 10); //try using the speed in more than one way speedY[i] = random(-10, 10); //use them to change the speed when they hit a wall sizeW[i] = random(20, 25); sizeH[i] = random(20, 100); //colors[i] = int(random(150, 100)); //strA = {"Zack", "Trevor", "Lisa", "Chris"}; shapez[i] = int(random(0,2)); } } void draw() { background(c,c,c); background(random(255),random(255),random(255)); fill(0); rect(40, 40, width-80, height-80); for (int i = 0; i < posX.length; i++) { posX[i] += speedX[i]; posY[i] += speedY[i]; fill(random(255),random(255),random(255)); //rect(posX[i], posY[i], sizeW[i], sizeW[i]); text(strA[i],posX[i], posY[i]+40); if (shapez[i] == 1) { rect(posX[i], posY[i], sizeW[i], sizeW[i]); } else { ellipse(posX[i], posY[i], sizeW[i], sizeW[i]); } if (posX[i] < 40+sizeW[i]/2 || posX[i] > (width-40)-sizeW[i]/2 ) { speedX[i] = -speedX[i]; if (shapez[i] == 1) { shapez[i] = 0; } else { shapez[i] = 1; } //^Code is toggle logic that changes shape at every x axis wall hit //Can use this to change the color of the objects and the background } if (posY[i] < 40+sizeW[i]/2 || posY[i] > (height-40)-sizeW[i]/2) { speedY[i] = -speedY[i]; } } //saveFrame("ZMex3-#####.png"); }