Externally Generating a Godot 4.x TileMap

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DizzyThermal

Hello,

I’m porting graphics from an old game to be used in Godot.

In Godot 3.x I would create the TileSets and manually create the PoolIntArray for the Map’s Scene. This worked in Godot 3.x

The values were 3 values per tile:

  • Tile location
  • Tile ID
  • Flags (I’ve been setting this to 0 for now)

With Packed32IntArray is this still possible? It didn’t seem to make sense with my single tile tests, I couldn’t make sense of the values in the Packed32IntArray string.

I’m guessing it’s bit-shifted in and the only way to generate the string would be to use a “Packed32IntArray” in Java or Python and then perform a “dump” to get the string.

Thanks in advance,
-DizzyThermal

:bust_in_silhouette: Reply From: DizzyThermal

Okay, so I took some notes:

    Tile Atlas 10x100 (WxH) of Tiles

    (tile_location, tile_id_x, tile_id_y)

                       X  Y     tile_data
    Tile #0 placed at (0, 0):   (0, 1, 0)
    Tile #1 placed at (0, 0):   (0, 1, 1)
    Tile #2 placed at (0, 0):   (0, 1, 2)
    Tile #9 placed at (0, 0):   (0, 1, 9)

    Tile #9 placed at (1, 0):   (1, 1, 9)
    Tile #9 placed at (2, 0):   (2, 1, 9)
    Tile #9 placed at (0, 1):   (65536, 1, 9)
    Tile #9 placed at (0, 2):   (131072, 1, 9)

    :: Next Column ::
    Tile #10 placed at (0, 0):  (0, 65537, 0)
    Tile #11 placed at (0, 0):  (0, 65537, 1)
    Tile #12 placed at (0, 0):  (0, 65537, 2)
    Tile #19 placed at (0, 0):  (0, 65537, 9)

    :: Next Column ::
    Tile #20 placed at (0, 0):  (0, 131073, 0)
    Tile #21 placed at (0, 0):  (0, 131073, 1)
    Tile #29 placed at (0, 0):  (0, 131073, 9)

    Tile Locations:
    [  0   ] [  1   ] [  2   ] ... x
    [65536 ] [65537 ] [65538 ]
    [131072] [131073] [131074]
       .
       .
       .
       y

I was previously using single tiles per file, now with an Atlas the values appear to be:

  • Tile location (on TileMap - refer to Tile Location grid above)
  • Tile Atlas X (65536 * X + 1)
  • Tile Atlas Y (Y)

The confusion stemmed from changing format (Single Tile → Atlas) which changed the data in the tile_data from: (tile_location, tile_id, flags) to (tile_location, tile_id_x, tile_id_y)