Please Help me, I'm having trouble with some Code, trying to create a checkerboard
in
Programming Questions
•
1 year ago
I have to create an assignment using loops and conditionals... Ok so I created a 8x8 grid checkerboard, But, i want to make it white and black, how do I do that please help? The code Below is what i'm working with on processing. I've tried soo many things but i cant figure it out. I tried if statements and all that but I cant seem to get it.
int NumBars = 35;
int cols, rows;
void setup() {
size(280,280); // 280/8 = 8x8 grid full screen. The size has to be divided by 8.
cols = width/NumBars; // height/35 - this makes the height go up the screen
rows = height/NumBars; // width/35 - this makes it go across the screen
}
void draw() {
// Begin loop for columns
for (int i = 0; i < cols; i++) { // Height
// Begin loop for rows
for (int j = 0; j < rows; j++) { //Width
// Scaling up to draw a rectangle at (x,y)
int x = i*NumBars; // height
int y = j*NumBars; // width
stroke(0);
// For every column and row, a rectangle is drawn at an (x,y) location scaled and sized by videoScale.
rect(x,y,NumBars,NumBars);
}
}
}
please help thanks
int NumBars = 35;
int cols, rows;
void setup() {
size(280,280); // 280/8 = 8x8 grid full screen. The size has to be divided by 8.
cols = width/NumBars; // height/35 - this makes the height go up the screen
rows = height/NumBars; // width/35 - this makes it go across the screen
}
void draw() {
// Begin loop for columns
for (int i = 0; i < cols; i++) { // Height
// Begin loop for rows
for (int j = 0; j < rows; j++) { //Width
// Scaling up to draw a rectangle at (x,y)
int x = i*NumBars; // height
int y = j*NumBars; // width
stroke(0);
// For every column and row, a rectangle is drawn at an (x,y) location scaled and sized by videoScale.
rect(x,y,NumBars,NumBars);
}
}
}
please help thanks
1