xxxxxxxxxx
30
//----ROAD CLASS----\\
class Road{
constructor(x1,y1,x2,y2){
this.start = createVector(x1,y1);
this.end = createVector(x2,y2);
this.lights = [];
this.cars = [];
this.points = [];
}
addLight(l){
this.lights.push(l);
}
addCar(c){
this.cars.push(c);
}
updatePoints(){
this.points.push(this.start);
for(let l of this.lights){
this.points.push(createVector(l.pos.x,l.pos.y + lightDisplacement));
}
this.points.push(this.end);
}
display(){
line(this.start.x,this.start.y,this.end.x,this.end.y);
}
}