xxxxxxxxxx
28
//seeking "vehicle" follows the mouse position
//implements Craig Reynold's autonomous steering behaviors
//one vehicle "seeks"
let v;
function setup() {
createCanvas(560,390);
let text = createP("Move mouse to interact");
text.position(15, 5);
v = new Vehicle(width / 2, height / 2);
}
function draw() {
background(220);
let mouse = createVector(mouseX, mouseY);
//draw an ellipse at the mouse position
fill(100);
stroke(50);
strokeWeight(2);
ellipse(mouse.x, mouse.y, 48, 48);
//call the appropriate steering behaviors for agents
v.seek(mouse);
v.update();
v.display();
}