xxxxxxxxxx
36
function Flower(x, y) {
this.x = x;
this.y = y;
this.r = 30;
this.xdir = 1;
this.grow = function() {
this.r = this.r + 2;
};
this.shiftDown = function() {
this.xdir *= -1;
this.y += this.r;
};
this.move = function() {
this.x = this.x + this.xdir;
};
this.show = function() {
noStroke();
fill(255, 0, 200, 150);
beginShape();
for (var theta = 0; theta < 4 * PI; theta += PI / 100) {
var r = this.r * cos(1.5 * theta + PI / 2);
var x = r * cos(theta) + this.x;
var y = r * sin(theta) + this.y;
vertex(x, y);
}
endShape(CLOSE);
fill(255, 255, 0, 150);
ellipse(this.x, this.y, this.r, this.r);
};
}