xxxxxxxxxx
62
var harry;
var sally;
function setup() {
createCanvas(windowWidth, windowHeight);
background(232, 250, 210);
noStroke();
harry = new Face();
sally = new Face();
}
function draw() {
background(232, 250, 210);
harry.display();
sally.display();
if (mouseIsPressed) {
harry.diameter *= 1.05;
sally.xPos += 10;
}
}
function Face() {
this.xPos = random(width);
this.yPos = random(height);
this.diameter = random(40, 80);
this.b = random(0,255);
this.r = random(0,255);
this.display = function() {
// face
fill(this.r, 150, this.b);
ellipse(this.xPos, this.yPos, this.diameter, this.diameter);
// eyes
fill(0);
ellipse(this.xPos + 10, this.yPos, 5,8);
ellipse(this.xPos - 10, this.yPos, 5,8);
ellipse(this.xPos, this.yPos+10, 8, 5);
}
}
function Flower() {
this.xPos = random(width);
this.yPos = random(height);
this.diameter = random(20, 35);
this.display = function() {
ellipse(this.xPos, this.yPos, this.diameter, this.diameter);
ellipse(this.xPos + 20, this.yPos, 15, 15);
ellipse(this.xPos - 20, this.yPos, 15, 15);
ellipse(this.xPos, this.yPos + 20, 15, 15);
ellipse(this.xPos, this.yPos - 20, 15, 15);
ellipse(this.xPos + 15, this.yPos - 15, 15, 15);
ellipse(this.xPos + 15, this.yPos + 15, 15, 15);
ellipse(this.xPos - 15, this.yPos - 15, 15, 15);
ellipse(this.xPos - 15, this.yPos + 15, 15, 15);
} // end display method
}; // end Flower constructor