I'm currently changing an existing computer game from a top-down view to an isometric view. The map consists of an infinite number of tiles. Only the tiles which are currently visible in the players window should be shown.
What i know is:
- How many pixels the worldmap has been scrolled on x and y axis
- The width and height of a single tile
- The width and height of the players window
What i need to know is
- The coordinates of the first tile to be shown
- The amount of tiles that will fit in the players window
To visualize the old approach was something like this (the dashed square represents the players window):
So with the old approach this calculation was pretty simple.
The new one looks like this:
And this is where i'm stuck at the moment. I can't figure out how to calculate which tile is in the upper left corner of the players window and how many tiles fitting inside the players window on the two new axes.
Can anyone help me with that? If yes, it would be really nice if the solution also contains a short explanation.
Thanks a lot in advance.