Public Group

# Flexible world coordinates independant of tile size

This topic is 3686 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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!

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5

• 11
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633723
• Total Posts
3013541
×