Working on a starfield
in
Programming Questions
•
11 months ago
Hey guys I'm trying to work on a moving star field at the moment I want it to kinda move on the Y axis and repeat right now I have a simple while to repeat the my ellipses going to the right and have random blinking to give them that twinkle like stars was wondering how would I animated them to move up the Y axis and then repeat over to give it the feel of upward movement
- //Global Varibles
float y = 50; //vertical location of each star
float x = 10; //intial horizontal location of the first line
float y1 = 50; //vertical location of each star
float x1 = 50; //intial horizontal location of the first line
float Cid = 5; //width of the ellipse
float spacing = 20; //How far apart is each star
float spacing1 = 10; //How far apart is each star
float dia = 5; //height ofeach star
float endStars = 500;
//colorGroup variables that we are going to use random to play with
float r;
float g;
float b;
float a;
//Global Varibles
void setup(){
size(500,500);
smooth();
background(0);
ellipseMode(CENTER); // setting up the ellipse in center
}
void draw(){
starField(0,50,4,4);
}
void starField(float x, float y,float cid,float dia){
r = random(255);
g = random(255);
b = random(255);
a = random(255);
while (x <= endStars){
fill(r,g,b,a);
ellipse(x,y,Cid,dia);
x = x + spacing;
}
}
1