xxxxxxxxxx
int fillStyle=0;
int squares = 20; //How many squares to a side?
int boardSize = 600; //Set pixel size for the board itself within the window.
float dx = boardSize/squares; //Size of each square in the board
int step = 0;
int turn = 1;
int interval = 1;
boolean isRed = true; //Determines if the first checker will be red or not
//The drawCheckerboard function separates the step of drawing the checkerboard
//from the rest of the function in case it needs to occur multip.
void drawCheckerboard(){
for(int i = 0;i<squares;i++){ //Set up a nested loop for the rows & columns
for(int j = 0;j<squares;j++){
fill(fillStyle); //Set the fill color to be the color stored in fillStyle
rect(j*dx,i*dx,dx,dx); //Draw the square
if(fillStyle==0){ //Switch the fill color variable after drawing each square
fillStyle=255;
}
else{
fillStyle=0;
}
}
if(squares%2==0 && fillStyle==0){ //If there is an even # of squares, switch the color at the end of the row. Otherwise, you get stripes!
fillStyle=255;
}
else if(squares%2==0 && fillStyle==255){
fillStyle=0;
}
}
}