-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Staggered and hex map coordinate conversion is bork #113
Comments
staggered? Do you mean staggered isometric? |
Yes. On Jul 27, 2016 9:54 PM, "buckle2000" [email protected] wrote:
|
In my opinion, using 2 non-whole numbers can never represent a hex tile correctly. |
What? |
Here is a good reference for hexagons |
Thanks, I'll have a look. |
@BradFitz66 Did you have a look at whether c732a6c fixes it? If so, you could open a new PR with that change (or your own version) since the one #262 came from has been deleted. |
@bjorn Just incase I'm doing this incorrectly, my code is below: local mx,my = love.mouse.getPosition()
tx,ty = map:convertPixelToTile(mx,my)
tx=math.floor(tx)
ty=math.floor(ty)
if(love.mouse.isDown(1)) then
map:setLayerTile(1,tx,ty,0)
end |
Using the
convertTileToPixel
andconvertPixelToTile
methods, getting the pixel location or the tile location of a point is very important. This can be used for, say, clicking your map with your mouse to have a player path to that location, or some such thing. This feature works perfectly fine for both ortho and iso maps. However, hex and staggered maps are totally broken in this regard, and I cannot seem to figure out the math to fix them.Like ortho/iso, I'd like to be able to retrieve non-whole numbers for tiles so you can know the relative location within a tile that the user clicked on. Users can then
floor
that number if they want the whole number representation of the tile.The text was updated successfully, but these errors were encountered: