xxxxxxxxxx
33
// Defining Star Class
class Star {
constructor(tx, ty, tc, tf, td) {
this.x = tx;
this.y = ty;
this.c = tc;
this.f = tf * 2;
this.down = td;
}
showStar() {
stroke(this.c);
strokeWeight(2);
point(this.x, this.y);
}
// Creating Twinkle Effect
twinkle() {
if (this.c >= 255) {
this.down = true;
}
if (this.c <= 0) {
this.down = false;
}
if (this.down) {
this.c -= this.f;
} else {
this.c += this.f;
}
}
}