xxxxxxxxxx
29
/* WE SET AN INITIAL BUTTON TO DISPLAY THE STARFIELD WHEN THE USER WANTS TO. THE STARS OF THE STARFIELD WILL BE CIRCLES OR TRIANGLES DEPENDING ON THE X POSITION OF THE MOUSE: */
// Array to store all the "Star" objects that will be created:
var stars = [];
function setup() {
createCanvas(1230, 670);
// We create, for instance, 1600 "stars":
for(let i = 0; i <= 1254; i++) {
stars.push(new Star());
}
}
function draw() {
background(0, 2, 22);
translate(width/2, height/2);
for(let j = 0; j < stars.length; j++) {
stars[j].update();
stars[j].render();
if(stars[j].z < 1) {
stars[j].reset();
}
}
}