xxxxxxxxxx
38
var font;
var vehicles = [];
var points;
var Ax = 100;
var Ay = 300;
function preload() {
font = loadFont("AvenirNextLTPro-Demi.otf");
}
function setup() {
createCanvas(800, 500);
points = font.textToPoints("p5js", Ax, Ay, 300);
for (var i = 0; i < points.length; i++) {
pt = points[i]
var vehicle = new Vehicle(pt.x, pt.y, i)
vehicles.push(vehicle)
}
}
function draw() {
background(22, 23, 26);
var Bx = mouseX;
var By = mouseY;
for (var i = 0; i < points.length; i++) {
vehicle = vehicles[i]
var dis = int(dist(vehicle.pos.x, vehicle.pos.y, Bx, By));
vehicle.update(dis);
vehicle.show();
}
}