Triangles[] tri = new Triangles[18];
int savedTime;
float totalTime = 5000;
float black = 0;
void setup()
{
size(900, 900);
background(0);
savedTime = millis();
for (int i = 0; i < tri.length; i++) {
float y = 0;
float x = 0;
tri[i] = new Triangles(x, y);
}
}
void draw()
{
background(220);
for (int i = 0; i < tri.length; i++) {
tri[i].change();
tri[i].display();
}
}
class Triangles {
float x;
float y;
Triangles(float tempX, float tempY) {
x = tempX;
y = tempY;
}
void display()
{
for (float x = 25; x < width; x+=50) {
for (float y = 0; y < height; y+=50) {
triangle(x, y, x+25, y+50, x-25, y+50);
}
}
}
void change() {
int passedTime = millis() - savedTime;
totalTime = random(0, 5000);
if (passedTime > totalTime) {
noStroke();
fill(black);
black += 1;
if (black == 255) {
black = 0;
savedTime = millis();
}
}
}
}
I tried moving the for loop to draw and got the error
“cannot find a class or type named Triangles”
Thankyou again. pointers are good though, I also don’t really want to just be handed everything on a plate here. 