Game Development Community

Honest answer please... Are tilemaps broken in TX2D??

by Randy Lutcavich · in Torque X 2D · 08/04/2009 (8:08 pm) · 2 replies

I've been poking around in the threads trying to find a solution to my simple problem. I haven't gotten many responses... I'm not sure how many people are working with TX2D these days but I just know I am not the only one seeing this issue with TX2D tilemaps.

The Simple Problem:
You can't seem to change a single tilemap based on it's world position. I say world position because you could of course paint any tile you want if you know the coords but what many people (like myself) need to do, is grab the location of a tile under an object such as a player and then change that specific tile. Changing the tile type seems to change all the tiles with that type which is just no good.

Honest Answer:
Can someone just give it to me straight?? Are tilemaps just broken here or am I really alone in my troubles?

#1
08/06/2009 (12:24 am)
Can't you just determine the coords from the world position in relation to the tilemaps world position and the tile sizes(and of course number of tiles...for finding out where 0,0 is)?

Something like:
Vector2 relativePosition = WorldPosition - (TileMap.Position - TileMap.Size/2);
int CoordX = (int)(relativePosition.X/TileMap.TileSize.X);
int CoordY = (int)(relativePosition.Y/TileMap.TileSize.Y);

Or something like. Don't blame me if my math is wrong since Im sleep deprived atm, but I think that's it.
#2
08/06/2009 (9:39 pm)
That's it!!!!!!!!!!!

I was thinking about it all wrong!

You sir have just made my month. Thank you!