Im stuck on step 1 help
i did this and it didn't let me to step 2
/*************
*OBJECT TYPES
**************/
/******************
*Flower Object Type
*******************/
/*****************
*Tulip Object Type
******************/
var Tulip = function(x, y, height) {
this.x = x;
this.y = y;
this.height = height;
};
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);
};
Tulip.prototype.growBy = function(amount) {
this.height += amount;
};
/*********************
*Sunflower Object Type
**********************/
var Sunflower = function(x, y, height) {
this.x = x;
this.y = y;
this.height = height;
};
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(245,400,135,133);
var sunflower = new Sunflower(100,150,200,200);
var superTulip = new Sunflower(200,200,100,50);
var superSunflower = new Sunflower(50,100,265,260);
var drawScene = function() {
tulip.draw();
sunflower.draw();
superTulip.draw();
superSunflower.draw();
};
mouseClicked = function() {
tulip.growBy(10);
sunflower.growBy(20);
drawScene();
};
drawScene();
Hozzászólások írásához jelentkezzen be.