Sign in to follow this  
hspirdal

Flexible world coordinates independant of tile size

Recommended Posts

Hi, I'm having this tile world created and I'm wondering if there's a neat way of making local coordinates relative to tile size? As an example, consider that I have a list of waypoints stored as vector coords for some sprites. These coords will represent different tile locations if I change my tile size from 64x64 to 128x128. To clear things up, I want my vector coords to point to the exact same spot in the same tile, regardless of changing tilesize or resolution.

Share this post


Link to post
Share on other sites
Make your tile coordinates in the range form 0 to 1.
Then to convert to actual coordinates you just need so multiply your tile coordinates with the size of the tile, e.g.:


a = (0.3, 0.7)
tSize = 64
tCoord = (a.x * tSize, a.y * tSize) = ( 19, 45 )



a = (0.3, 0.7)
tSize = 128
tCoord = (a.x * tSize, a.y * tSize) = ( 38, 90 )

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this