XNA - Finding boundaries in isometric tilemap

Posted by Yheeky on Game Development See other posts from Game Development or by Yheeky
Published on 2014-06-02T21:41:21Z Indexed on 2014/06/02 21:48 UTC
Read the original article Hit count: 316

Filed under:
|
|
|

I have an issue with my 2D isometric engine. I'm using my own 2D camera class which works with matrices and need to find the tilemaps boundaries so the user always sees the map. Currently my map size is 100x100 (with 128x128 tiles) so the calculation (e.g. for the right boundary) is:

var maxX = (TileMap.MapWidth + 1) * (TileMap.TileWidth / 2) - ViewSize.X;
var maxX = (100 + 1) * (128 / 2) - 1360; // = 5104 pixels.

This works fine while having scale factor of 1.0f but not for any other zoom factor. When I zoom out to 0.9f the right border should be at approx. 4954. I´m using the following code for transformation but I always get a wrong value:

var maxXVector = new Vector2(maxX, 0);
var maxXTransformed = Vector2.Transform(maxXVector, tempTransform).X;

The result is 4593.

Does anyone of you have an idea what I´m during wrong? Thanks for your help!

Yheeky

© Game Development or respective owner

Related posts about XNA

Related posts about engine