icrawler / HexaMoon

Hexagonal Grid Library for Lua
GNU General Public License v2.0
27 stars 2 forks source link

Size is undefined #3

Open Yureii opened 5 years ago

Yureii commented 5 years ago

https://github.com/icrawler/HexaMoon/blob/9594d8b7f8d791e5ae3c30a195053fabbaf564d2/HexaMoon.lua#L46

kirilldev commented 4 years ago

I experienced the same problem.The fix will be:

function hxm.getCoordinates(rad, x, y, ox, oy) local height = 2 rad local width = (math.sqrt(3) / 2) height

local rx = x * width + 0.5 * y * width + ox
local ry = 0.75 * y * height + oy

return { x = rx, y = ry }

end