Hello! I’m trying to make my background of stars randomly scale. I used a 2D array of class Star to display what I have right now. I’m very new to processing so explaining this to me in basic terms would be very much appreciated! Here is my code:
Star st;
Star [][] starArray;
void setup() {
size(800, 600);
st = new Star();
starArray = new Star[10][10];
for (int i=0; i<10; i++) {
for (int j=0; j<10; j++) {
//println("For");
starArray[i][j]= new Star(i*10, j*10);
}
}
}
void draw () {
background(30, 85, 147);
for (int i=0; i<10; i=i+1) {
for (int j=0; j<10; j=j+1) {
starArray[i][j].display();
}
}
}
class Star {
color starColor;
float x;
float y;
Star(float i, float j) {
this.starColor= color(247,236,96);
this.x=j*10;
this.y=i*10;
}
void display() {
stroke(starColor);
line(x,y, x,y+20);
line(x,y, x,y-20);
line(x,y,x-20,y);
line(x,y,x+20,y);
line(x-10,y+10,x+10,y-10);
line(x-10,y-10,x+10,y+10);
}
}