// Many spinning and bouncing smiley faces - object oriented! v2 // Gian Pablo Villamil // Intro Comp Media // September 24, 2006 // New version varies the size of the face, // and spins them. // // The smileys alternate between loving and fearing the mouse, based on clicking // declare constants // Processing doesn't have #define??? int numFaces = 20; int theWidth = 640; int theHeight = 480; Smiley[] theSmileys = new Smiley[numFaces]; int attracted = 1 ; // defines whether the smileys love or fear the mouse (fear = -1) void setup() { size(640,480); // worked locally with variables, but not on web - bug? framerate(30); smooth(); // anti-alias background(0,0,0); colorMode(HSB,100); // I want bright colors! // // initialize array of faces // for (int i=0; i < numFaces; i++) { theSmileys[i] = new Smiley(); } } // Draw and move the smileys void draw() { background(0,0,0); // clear the screen for (int i=0; i < numFaces; i++) { // Draw the face theSmileys[i].DrawIt(); // Move the face theSmileys[i].MoveIt(); } } // Toggle between fear and attraction void mousePressed() { if (attracted == 1) {attracted = -1;} else {attracted = 1;} } // Function to return a random color // Note use of color variable type // Return syntax very different from Pascal color RandomColor() { return color(random(100), 100,100); // random is not really random }