# How do I calculate the visible area of a big isometric map? [duplicate]

I have a simple isometric map of 128px x 128px, tile in a 2D field [xxxx][xxxx] I have a problem with my calculating. I need to get startx:[0], startY[0] and endX[20], endY[10], if I know the screen width and height, and the camera offset like this:

(not effective for big maps)

This is my current code:

starti = (-camera.xOffset - tileWidth) / 64;
int endi = (-camera.xOffset + camera.width + tileWidth) / 64;
int startj = (-camera.yOffset - tileHeight) / 64;
int endj = (-camera.yOffset + camera.height + tileHeight) / 64;

Point start = twoDToIso(new Point(startx,starty));
Point end = twoDToIso(new Point(endx, endy));
for (int i = start.X; i < end.X; i++)
{
for (int j = start.Y; j < end.Y; j++)
{


This does not work; it will create something like this:

It does something, but when I move and my offset is changed, it does not work at all. How do I calculate the visible lines on a big isometric map?

• The last time I wrote an isometric engine I was a bit lazy and drew a diamond-shape with the corners outside of the screen. This wasn't much of a problem because in the API I was using (html5 canvas) the cost for drawing outside of the screen was almost none. Would that solution be good enough for you, too? Jul 17 '17 at 16:07
• not sure if it would help, i have code that is efficient for 500*500 tile map with stable FPS but i needed to change it into Tile[x][y], now if i can calculate right way to get tiles that are visible i can get easy map of 5000*5000 it will be just memory issue but that can be soved by loading chunks ahead of camera movement Jul 17 '17 at 16:50
• There have been many related questions about mapping from screen coordinates back to isometric map coordinates. gamedev.stackexchange.com/questions/45103 gamedev.stackexchange.com/questions/34787 gamedev.stackexchange.com/questions/12362 gamedev.stackexchange.com/questions/65968 gamedev.stackexchange.com/questions/32350 Jul 17 '17 at 21:12