Hi
Sun sun1;
Hill hill1;
Hill hill2;
Star[] stars = new Star[2];
float r = 0;
float g = 0;
float b = 200;
void setup() {
size(600, 400);
sun1 = new Sun();
hill1 = new Hill(0);
hill2 = new Hill(width);
for (int i = 0; i < stars.length; i++) {
stars[i] = new Star(100, 100);
}
}
void draw() {
background(r, g, b);
noStroke();
sun1.display();
sun1.sunset();
hill1.display();
hill2.display();
for (int i = 0; i < stars.length; i++) {
stars[i].display();
}
}
float xStar;
float yStar;
class Star {
Star(float tempXStar, float tempYStar) {
xStar = tempXStar;
yStar = tempYStar;
}
void display() {
fill(255);
rect(xStar, yStar, 2, 2);
}
}
So in my code I’d like to make many stars on the screen using an array. I’d like to change the x and y position of each star. So far I have two stars in the array with both the same x and y position. The co-ordinates of each star are in the arguments of the constructor. Would anyone be able to explain to me how to change the value of x and y for each star?
Thanks in advance!