Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var number= 1000;
- class Star{
- constructor(){
- this.x=random(-0.006*width,0.006*width)
- this.y=random(-0.006*height,0.006*height)
- this.ox=random(-0.006*width,0.006*width)
- this.oy=random(-0.006*height,0.006*height)
- this.size=1
- this.vel=1
- }
- show(){
- fill(255);
- translate(width/2,height/2);
- ellipse(this.x,this.y,this.size,this.size);
- stroke(255)
- strokeWeight(0.01)
- line(this.x,this.y,0,0)
- translate(-width/2,-height/2);
- }
- move(){
- this.x=(this.x*this.vel)
- this.y=(this.y*this.vel)
- this.vel+=this.vel/(width+height)/1
- this.size=map(abs(this.x)+abs(this.y)/2,0,width/2+height/42,2,10)
- }
- reborn(i){
- if(this.x>width/2||this.x<-width/2||this.y>height/2||this.y<-height/2){
- s[i]=new Star()
- }
- }
- }
- let s= [];
- let start=true;
- function setup() {
- createCanvas(600, 400);
- frameRate(120);
- for(let i=0;i<number;i++){
- s[i]=new Star();
- }
- }
- function draw() {
- background(0);
- if(start){
- for(let i=0;i<10000;i++){
- for(let i=0;i<number;i++){
- s[i].move()
- s[i].reborn(i)
- }
- }
- start=false
- }
- for(let i=0;i<number;i++){
- s[i].show()
- s[i].move()
- s[i].reborn(i)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment