Open karai17 opened 8 years ago
staggered? Do you mean staggered isometric?
Yes.
On Jul 27, 2016 9:54 PM, "buckle2000" notifications@github.com wrote:
staggered? Do you mean staggered isometric?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/karai17/Simple-Tiled-Implementation/issues/113#issuecomment-235766869, or mute the thread https://github.com/notifications/unsubscribe-auth/AAkB_KIu_GkTWOg4tcUaoqqxYoxssNzaks5qZ_3GgaJpZM4JUL5e .
In my opinion, using 2 non-whole numbers can never represent a hex tile correctly. And is the pixel origin (0,0) of staggered and hex map useful to the user?
What?
Here is a good reference for hexagons http://www.redblobgames.com/grids/hexagons/implementation.html
Thanks, I'll have a look.
I know this is an old issue, but it appears that staggered coordinates are still broken.
Unless I'm using convertPixelToTile wrong, that is. I'm getting mouse coordinates via love.mouse.getPosition() and then using those as the arguments for convertPixelToTile and then attempting to delete (setLayerTile to GID 0) using the coordinates it gives me, but it doesn't seem to work.
Here's what I'm seeing(white circle represents my cursor):
Map is a staggered isometric type map.
@BradFitz66 Did you have a look at whether https://github.com/karai17/Simple-Tiled-Implementation/pull/262/commits/c732a6c065d4492809feb5a470d334d7cce6856e 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.
@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 Unfortunately, it does not seem to work either.
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
Here's the result:
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.