Jump to content

Tile coords to world point

Recommended Posts

I can't find an actual function to do this, but try searching for the word "TILE_SCALE" in the game code (without the quotes). You'll get a lot of lines like this

local x = (posX - mapWidth/2.0)*TILE_SCALE
local z = (posY - mapHeight/2.0)*TILE_SCALE


Link to comment
Share on other sites

Since it probably goes in both directions from the middle of the tile, I think you need to halve the scale.

+ math.random(-(HALF_TILE_SCALE -1), HALF_TILE_SCALE -1)

Btw, if you didn't know, Lua's math.random is inclusive of both given values, so

math.random (4, 8)  --> (a number from 4 to 8)

So you only need the -1 if you don't want the resulting position to be at the edges of a tile.

Link to comment
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

  • Create New...