Trying to make a simple for loop drawing blocks within a rectangle
in
Programming Questions
•
1 year ago
I thought this would be easy, and it should be. But here is my problem. In the for loop, the blocks are drawing spaces in between and running off the screen. The size of each square is equal to the distance of the 1st rect / 10 ( or at least I'm pretty sure). Each time the loop iterates, there is a space I believe to be 175 pixels between the new rect. When I manipulate the 'x' component of the rect() the squares will eventuall overlap but will be too big for the rect() i'm drawing in. Can someone please help?
void gameBoard() {
float x = width*.175;
float y = height*.175;
rectMode(CENTER);
//rect1 outlines game board
rect(width/2,height/2,width*.75,height*.75);
//i = amount of game spaces - 10
for(int i = 1; i < 11; i++) {
//rect2
//reason for w & h / 10 is equal to width of rect2 / 10
rect(x*(i) ,y,width/10,height/10);
}
}
1