xxxxxxxxxx
46
var x = 200;
var y = 200;
var y2 = 230;
var x2 = 230;
var bee;
function setup() {
createCanvas(400, 400);
fields = loadImage("field.jpg");
bee = loadImage("bee.png");
frameRate(10);
}
function draw() {
image(fields, 0, 0, 500, 500);
image(bee, x, y, 50, 50);
image(bee, x2, y2, 50, 50);
if (mouseX < x) {
x = x + random(-6, 2);
} else if (mouseX > x) {
x = x + random(-2, 6);
}
if (mouseY < y) {
y = y + random(-6, 2);
} else if (mouseY > y) {
y = y + random(-2, 6);
}
if (mouseX < x2) {
x2 = x2 + random(-20, 10);
} else if (mouseX > x) {
x2 = x2 + random(-10, 20);
}
if (mouseY < y2) {
y2 = y2 + random(-20, 10);
} else if (mouseY > y) {
y2 = y2 + random(-10, 20);
}
}