mapeditor / tiled

Flexible level editor
https://www.mapeditor.org/
Other
11.23k stars 1.76k forks source link

Hexagonal map exporting with weird values #1098

Open karai17 opened 9 years ago

karai17 commented 9 years ago

I believe this issue is related to issue #1097. Because Hexagonal are actually isometric maps, the value being pushed out to Lua for the tile width is a bit strange. With a hex tile size of 32x32, the map tile width is exported as 51. This causes rendering issues that are only solved by changing the value to 50 in my library.

if self.orientation == "hexagonal" then
    self.tilewidth = self.tilewidth - 1
end

I think it might be better to treat hex tiles as orthogonal instead of isometric.

bjorn commented 9 years ago

Erm, the tilewidth property should exactly match what you told Tiled about the tile width in the New Map dialog and the Map Properties widget:

    writer.writeKeyAndValue("tilewidth", map->tileWidth());
    writer.writeKeyAndValue("tileheight", map->tileHeight());

So where does this value of 51 come from?

EntranceJew commented 9 years ago

I think the problem stems from not using the side-length property, but the 51 should be 50 in this scenario, the problem was that the results of having it at 51 and 50 had identical results: fifty one fifty

50 comes from tile_width + side_length, which is what would fix the map if it was staggered along the correct axis and made correct use of the side length property: the same map, configured correctly

As mentioned in #1097, this came from (me) not really understanding the significance of the stagger axis, as it only seemed to modify the map dimensions and didn't seem to correlate with how the hex was oriented with the default side length being zero.

bjorn commented 9 years ago

51 rendering the same as 50 has to do with the offset between tiles, which can't be half pixels.

karai17 commented 9 years ago

Perhaps forcing this value to always be even would help with this particular confusion? Or maybe throw a warning if someone sets it to odd?

bjorn commented 9 years ago

I think the problem is, should I then force it to be always odd, when the tile side length is odd?

karai17 commented 9 years ago

I think the idea here is that we need the numbers to export in a way that will not cause errors in a renderer.