You should replace board[x][y]
with board[y][x]
since the first index represents the blocks so when x=0
the vector coming out of the matrix is {0,-1,-1}
if you don't want to change x
with y
,
you can switch for
loops
first loop the y
and then loop the x
first solution would look like this:
for(byte x = 0; x < 3; x++) for(byte y = 0; y < 3; y++) if(board[y][x] == 0) drawX(g, x, y);
else if(board[y][x] == 1) drawO(g, x, y);
the second solution would look like this
for(byte y = 0; y < 3; y++) for(byte x = 0; x < 3; x++) if(board[x][y] == 0) drawX(g, x, y);
else if(board[x][y] == 1) drawO(g, x, y);