xxxxxxxxxx
46
class Bee {
constructor() {
this.x = 300;
this.y = 200;
this.xspeed = 3;
this.yspeed = 1;
}
move() {
this.x = this.x + this.xspeed;
this.y = this.y + this.yspeed;
}
bounce() {
if (this.x > width || this.x < 0) {
this.xspeed = this.xspeed * -1;
}
if (this.y > height || this.y < 0) {
this.yspeed = this.yspeed * -1;
}
}
show() {
// bee's wing
fill("#D5EBEE");
stroke('#C6D8E0');
ellipse(this.x-2, this.y-15, 17, 21);
ellipse(this.x+5, this.y-15, 15, 20);
// bee's body
stroke('#E7D534');
strokeWeight(3);
fill("#FFEB3B");
ellipse(this.x, this.y, 40, 30);
fill('rgb(15,15,15)');
noStroke();
ellipse(this.x, this.y, 3, 30);
ellipse(this.x-8, this.y, 3, 25);
ellipse(this.x+8, this.y, 3, 25);
}
}