# 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 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 = 64tCoord = (a.x * tSize, a.y * tSize) = ( 19, 45 )

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

##### Share on other sites
That's awesome. Thanks a bunch, dragongame!

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628394
• Total Posts
2982431

• 10
• 9
• 19
• 24
• 9