My head is starting to hurt from trying to figure out why my grid renders as this:
http://billedeupload.dk/images/ZqMWJ.png
I have this code to generate my grid from a two-dimensional array (currently just the upper 3 rows)
// Get the board tiles
Field[][] tiles = board.getTiles();
int distanceX = 0;
int distanceY = 0;
int currentRowTiles = 0;
for (int x=0; x < tiles.length ; x++) {
for (int y=0; y < tiles[x].length ; y++) {
if (currentRowTiles == 16) {
distanceX = 0;
distanceY += 50;
currentRowTiles = 0;
}
// Get current tile
Field tile = tiles[x][y];
int fieldX = tile.getX() + distanceX;
int fieldY = tile.getY() + distanceY;
g.setColor(tile.getColor());
g.fillRect(fieldX, fieldY, 50, 50);
distanceX += 50;
currentRowTiles += 1;
}
}
I hope someone can help me out!