xxxxxxxxxx
34
class Star {
constructor(color_) {
this.pos = createVector(random(-width, width), random(-height, height));
this.z = random(width);
this.pz = this.z;
this.r = 4.2;
this.speed = 20;
}
update() {
this.z -= this.speed;
if(this.z < 1) {
this.pz = this.z;
}
}
render(color_) {
let cX = map(this.pos.x / this.z, 0, 1, 0, width);
let cY = map(this.pos.y / this.z, 0, 1, 0, height);
stroke(color_);
strokeWeight(this.r);
point(cX, cY);
}
reset(color_) {
this.pos = createVector(random(-width, width), random(-height, height));
this.radius = 1;
this.z = random(width);
}
}