xxxxxxxxxx
65
let bees = [];
function setup() {
createCanvas(400, 400);
angleMode(DEGREES);
}
function draw() {
background("#504C4C");
// Draw flowers and leaves
flower(200, 100, 30);
flower(100, 200, 30);
flower(300, 300, 30);
leaf(200, 250, 0);
leaf(100, 310, 0);
leaf(200, 350, 0);
// Update and show bees
for (let i = 0; i < bees.length; i++) {
bees[i].show();
bees[i].move();
bees[i].bounce();
}
}
// Handle mouse press
function mousePressed() {
let manyBees = new Bee(mouseX, mouseY, random(-10, 10), random(-1, 10));
bees.push(manyBees);
}
// Draw leaves
function leaf(x, y, diameter) {
fill("#265812");
stroke("#194906");
ellipse(x, y, 40, 15);
}
// Draw flowers
function flower(x, y, diameter) {
push();
// Flower stem
stroke("#194906");
fill("#265812");
rect(x - 5, y, 10, 300);
// Flower core
stroke("#52260F");
fill("#723819");
ellipse(x, y, diameter);
// Flower petals
translate(x, y);
stroke("rgb(218,207,99)");
strokeWeight(3);
fill("rgb(228,218,122)");
for (let angle = 0; angle <= 360; angle += 45) {
rotate(angle);
ellipse(0, 35, 20, 40);
}
pop();
}