With this code I draw a isometric chessboard out of single board-pieces bmpWhite
and bmpBlack
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 7; j++) {
if (white == true) {
color[i][j] = 0;
white = false;
}
else {
color[i][j] = 1;
white = true;
}
}
}
}
public void onDraw(Canvas canvas)
{
if (gameViewWidth == 0)
{
gameViewWidth = theGameView.getWidth();
gameViewHeight = theGameView.getHeight();
}
for (int xx=0; xx < 7; xx++)
{
for (int yy=0; yy < 7; yy++)
{
int x_start=(yy * 23);
int y_start=(gameViewHeight / 2) + (yy * 12);
int xx1=x_start + (xx * 23);
int yy1=y_start - (xx * 12);
if (color[xx][yy] == 0)
{
canvas.drawBitmap(bmpWhite, xx1, yy1, null);
}
else if (color [xx][yy] == 1)
{
canvas.drawBitmap(bmpBlack, xx1, yy1, null);
}
}
}
The output should a chessboar(8x8) with alternating colors. But the output is this:
As you can see the last two lines of the bottom and top are the same color. What did I do wrong?