Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
raykstar authored Nov 4, 2017
1 parent bf970fd commit 19eb190
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Star.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
class Star{
float x;
float y;
float z;

float speed;

Star(){
x = random(-width, width);
y = random(-height, height);
z = random(width);

}

void update(){
if(mouseX<width/2)
speed = map(mouseX, 0,width/2,0 , 50);
else
speed = map(mouseX,width/2,width,50,0);
z=z-speed;

if(z<1){
x = random(-width, width);
y = random(-height, height);
z = random(width);

}
}

void show(){
fill(215,204,222);
noStroke();

float sx = map(x/z,0,1,0,width);
float sy = map(y/z,0,1,0,height);

float size = map(z,0,width,8,0);
ellipse(sx,sy,size,size);
}
}
17 changes: 17 additions & 0 deletions Starfield.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Star[] stars = new Star[1000];

void setup(){
size(1720,800);
for(int i=0;i<stars.length;i++){
stars[i] = new Star();
}
}

void draw(){
background(0);
translate(mouseX,mouseY);
for(int i=0;i<stars.length;i++){
stars[i].update();
stars[i].show();
}
}

0 comments on commit 19eb190

Please sign in to comment.