https://editor.p5js.org/kamuridesu/sketches/3r2vO0k3m
function carFactory() {
let index = 0;
for (let i = 0; i < cars_coords_y.length; i++) {
if (index == car_images.length) {
index = 0;
}
let image = car_images[index];
cars[i] = {
x: cars_coords_x,
y: cars_coords_y[i],
velocity: cars_vels[i],
image: image
}
index += 1;
}
}
function showCar() {
cars.forEach((car) => {
image(car.image, car.x, car.y, car_width, car_height);
});
}