xxxxxxxxxx
135
let BumbleBee;
let FlowerImage;
let FlowerGrow = [];
let FlowerSize = 150;
function preload(){
FlowerImage = loadImage('sakura.png');
}
function setup() {
createCanvas(windowWidth, windowHeight);
BumbleBee = new Bee();
for (var i = 0; i < 8; i++) {
FlowerGrow.push(new Flower(i));
}
}
function draw() {
background(70, 200, 110);
BumbleBee.fly();
for (var i = 0; i < FlowerGrow.length; i++)
FlowerGrow[i].grow();
}
function mousePressed() {
for (var i = FlowerGrow.length - 1; i > -1; i--) {
if (FlowerGrow[i].imPregnant() < FlowerSize) {
FlowerGrow.splice(i, 1);
FlowerGrow.push(new Flower(i));
FlowerGrow.push(new Flower(i));
FlowerGrow.push(new Flower(i));
print("POLLEN POWER");
}
}
}
class Bee {
constructor() {
this.BeeWidth = 80;
this.x = mouseX
this.y = mouseY
this.R = 240
this.G = 210
this.B = 0
this.Xwing = 60
this.Ywing = 30
this.LwingPos = -70
this.RwingPos = 70
this.WingFlap = -10
//this.RwingMove = 0
//this.angle = PI
}
fly() {
//console.log(this.RwingMove)
this.RwingPos = this.RwingPos + this.WingFlap
this.LwingPos = this.LwingPos - this.WingFlap
this.Xwing = this.Xwing + this.WingFlap
//this.RwingMove = this.RwingPos + this.WingEnd
//rotateY(this.angle)
fill(this.R, this.G, this.B);
ellipse(this.x + mouseX, this.y + mouseY, this.BeeWidth, 120);
fill(0);
rectMode(CENTER);
rect(this.x + mouseX, this.y + mouseY, this.BeeWidth - 3, 38);
fill(255);
ellipse((this.RwingPos) + this.x + mouseX, this.y + mouseY, this.Xwing, this.Ywing);
ellipse((this.LwingPos) + this.x + mouseX, this.y + mouseY, this.Xwing, this.Ywing);
if (this.RwingPos < 40) {
this.WingFlap = this.WingFlap * -1;
} else if (this.RwingPos > 60) {
this.WingFlap = this.WingFlap * -1;
}
}
}
class Flower {
constructor() {
noStroke();
this.x = random(width);
this.y = random(height);
this.R = 200;
this.G = 10;
this.B = 150;
}
grow() {
// fill(this.R, this.G, this.B);
// ellipse(this.x, this.y, FlowerSize);
imageMode(CENTER);
image(FlowerImage, this.x, this. y, FlowerSize, FlowerSize);
}
imPregnant() {
return dist(this.x, this.y, mouseX, mouseY);
}
}