I want to combine these two lines but I don’t know how to.
for (int x=940; x<1001; x+=30);
for (int y=53; y<234; y+=30)
I want to combine these two lines but I don’t know how to.
for (int x=940; x<1001; x+=30);
for (int y=53; y<234; y+=30)
Hello, your mistake might be the ; after the first line
Delete this
Chrisir is right, the semicolon ends the first statement so you have two single loops rather than a double loop. I also suggest that you use { } to delineate the code blocks like this
for (int x=940; x<1001; x+=30) {
for (int y=53; y<234; y+=30) {
// code to be executed in double loop
}
}
Although the {} are not required if the code to be executed is a single statement I suggest you use them anyway because they
typical example
void setup() {
size(1200, 900);
}//func
void draw() {
for (int x=940; x<1001; x+=30) {
for (int y=53; y<234; y+=30) {
rect(x, y, 20, 20);
}
}
}//func
//
The problem is the ;
at the end of the 1st for
loop, which is making it a an already complete statement block, w/o incorporating the 2nd for
loop:
for (int x = 940; x < 1001; x += 30)
for (int y = 53; y < 234; y += 30) {
}
Another way (my fav btW):
for (int x = 940; x < 1001; x += 30) for (int y = 53; y < 234; y += 30) {
}