Challenge: Flower Grower - stuck on step 5
I'm stuck on step 5. I believe I've completed everything but it has the following error. I've looked on many other websites for answers and I can't figure out what's wrong.
Great ! Your Tulip prototype is now based off of the Flower prototype. Now call the Flower constructor from your Tulip constructor.
/*************
*OBJECT TYPES
**************/
/******************
*Flower Object Type
*******************/
/*****************
*Tulip Object Type
******************/
var Flower = function(x, y, height) {
this.x = x;
this.y = y;
this.height = height;
};
var Tulip = function(x, y, height) {
Flower.call = (this, x, y, height);
};
var Sunflower = function(x, y, height) {
Flower.call = (this, x, y, height);
};
Tulip.prototype = Object.create(Flower.prototype);
Sunflower.prototype = Object.create(Flower.prototype);
Tulip.prototype.draw = function() {
noStroke();
fill(16, 122, 12);
rect(this.x, this.y, 10, -this.height);
fill(255, 0, 0);
// petals
ellipse(this.x+5, this.y-this.height, 44, 44);
triangle(this.x-16, this.y-this.height,
this.x+20, this.y-this.height,
this.x-20, this.y-this.height-31);
triangle(this.x-14, this.y-this.height,
this.x+24, this.y-this.height,
this.x+3, this.y-this.height-39);
triangle(this.x+-4, this.y-this.height,
this.x+26, this.y-this.height,
this.x+29, this.y-this.height-36);
};
Flower.prototype.growBy = function(amount) {
this.height += amount;
};
/*********************
*Sunflower Object Type
**********************/
Sunflower.prototype.draw = function() {
fill(16, 122, 12);
rect(this.x, this.y, 10, -this.height);
// petals
stroke(0, 0, 0);
fill(255, 221, 0);
ellipse(this.x-10, this.y-this.height, 20, 18);
ellipse(this.x+5, this.y-this.height-15, 20, 18);
ellipse(this.x+5, this.y-this.height+15, 20, 18);
ellipse(this.x+20, this.y-this.height, 20, 18);
fill(20, 20, 20);
ellipse(this.x+5, this.y-this.height, 20, 20);
};
Sunflower.prototype.growBy = function(amount) {
this.height += amount;
};
/**************
*MAIN PROGRAM
***************/
/** create object instances **/
var tulip = new Tulip(38, 390, 150);
var newTulip = new Tulip(40,400, 200);
var sunflower = new Sunflower(186, 390, 100);
var newsunflower = new Sunflower(200, 400, 150);
var drawScene = function() {
background(207, 250, 255);
tulip.draw();
sunflower.draw();
newTulip.draw();
newsunflower.draw();
};
mouseClicked = function() {
tulip.growBy(10);
sunflower.growBy(20);
drawScene();
newTulip.growBy(20);
newsunflower.growBy(20);
};
drawScene();
Iniciar sesión para dejar un comentario.