# 2D Array Help needed

Hi, I am hoping someone can help me again with my Processing assignment. This is a red and black checker board. The question is “add one line of code that will create a circle using the ellipse function and place it on the black square as shown by the illustration.”

Here is what I have so far. The last line is the one that I can’t figure out. Thanks in advance for any help.

``````int squareSize = 50; // Dimensions ask for 40x40
int cols, rows;

void setup() {

size(500, 500); // Specified by assignment

// Initialize columns and rows
cols = 10; // Specified by assignment | size/squareSize
rows = 10; // Specified by assignment | size/squareSize
}

void draw() {

// Begin loop for columns
for (int i = 0; i < cols; i++) {
// Begin loop for rows
for (int j = 0; j < rows; j++) {

// Scaling up to draw a rectangle at (x,y)
int x = i*squareSize; // width
int y = j*squareSize; // height

// Begin fill controls
if ((i+j) % 2 == 0) { // Even is red
fill(250, 0, 0);
} else { // Odd is black
fill(0);
}

// For every column and row, a rectangle is drawn at an (x,y) location scaled and sized by videoScale.
rect(x, y, squareSize, squareSize);
fill(0,0,0);
fill(255);
ellipse(x,y, 40,40);  **// How do I move these to be only in the black squares?**

}
}
}
``````

does it mean one circle over each black field
( like you try over every field what could work if your white is same!
means the white circle in the white fields would be not visible. )

or does it mean one circle on a specific field?

anyhow
two fill commands / first black then white / not make sense
and fill fill ellipse are 3 lines???

and pls. repair your code posting using

``````</>
``````

code formatting.

The idea is to check whether you are in an even column plus uneven row or vice versa

You need an if clause :

`if ((i+j) % 2 == 0)`

or

`if(i%2==0 && j%2==0) {`

Chrisir