let vehicle;
let path;
function setup() {
createCanvas(600, 600);
vehicle = new Vehicle(50, 0);
}
function draw() {
background(220);
path.display();
vehicle.follow(path);
vehicle.update();
vehicle.display();
var redLight = 'red';
var yellowLight = 'white';
var greenLight = 'white';
var count = 0;
fill("black");
rect(140, 70, 110, 250);
fill(redLight);
ellipse(195, 120, 60, 60);
fill("white");
text("RED", 182, 124);
fill(yellowLight);
ellipse(195, 200, 60, 60);
fill("white");
text("YELLOW", 171, 205);
fill(greenLight);
ellipse(195, 280, 60, 60);
fill("white");
text("GREEN", 175, 285);
}
Having a traffic light and a path on the same canvas is a challenge. You need to adjust the positioning of each element so they don't overlap. Experimenting with different coordinates and sizes can help achieve this.