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:
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?