I have a problem which I am struggling to solve. I have a large map of around 100x100 tiles which form an isometric map. The user is able to move the map around by dragging the mouse. I am trying to optimize my game only to draw the visible tiles.
So far my code is like this. It appears to be ok in the x direction, but as soon as one tile goes completely above the top of the screen, the entire column disappears. I am not sure how to detect that all of the tiles in a particular column are outside the visible region.
double maxTilesX = widthOfScreen/ halfTileWidth + 4;
double maxTilesY = heightOfScreen/ halfTileHeight + 4;
int rowStart = Math.max(0,( -xOffset / halfTileWidth)) ;
int colStart = Math.max(0,( -yOffset / halfTileHeight));
rowEnd = (int) Math.min(mapSize, rowStart + maxTilesX);
colEnd = (int) Math.min(mapSize, colStart + maxTilesY);
EDIT - I think I have solved my problem, but perhaps not in a very efficient way. I have taken the center of the screen coordinates, determined which tile this corresponds to by converting the coordinates into cartesian format. I then update the entire box around the screen.