Jump to content
  • Advertisement
Sign in to follow this  
hspirdal

Flexible world coordinates independant of tile size

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

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!