Is it possible to use two variables in a single for loop? Here’s my non-working code:
void sqrNew() {
for (float x = random(295,300),float y = random(355,360); x < 700 && y < 700; x = x + 55, y = y + 55) {
noStroke();
fill(random(255),random(255),random(255));
rect(x,y,random(40,53),random(40,53));
println(x + " " + y);
}
}
I keep getting syntax errors. Is there a way to make this work, or are multiple variables in a single for loop not possible?
@sleepycode remove the second float declaration in the for loop
void sqrNew() {
for (float x = random(295,300), y = random(355,360); x < 700 && y < 700; x = x + 55, y = y + 55) {
noStroke();
fill(random(255),random(255),random(255));
rect(x,y,random(40,53),random(40,53));
println(x + " " + y);
}
}