Use TileMaps efficiently

I’m looking for advice/brainstorming on how to efficiently use the new TileMap objects.

Background:
I’m working on a game with about 80 levels, and around 10 themes. I’ve implemented all the collision maps in GDevelop using platform objects. I’m exporting those platform objects to LDTK maps using an extension I wrote: Extension to export GDevelop scenes to LDTK IntGrid layer · Issue #80 · GDevelopApp/GDevelop-extensions · GitHub
Then after auto-mapping the tiles based on the theme of the level I am saving those as TMX files, which I am then re-importing into GDevelop using the newly release TileMap objects.

Apparent Restrictions:

  • TileMap objects can only use a a single tileset
    ** I think this is fine, I can create a single merged tileset for each theme
  • TileMap atlas file seems required AND immutable
    ** This is a bit of a bummer, I thought using an external tileset json file would allow using a different atlas
    ** I think this means I have to create a TileMap object for each level theme with a hardcoded atlas file?
  • The TileMap object can change the TileMapFile and TileMapTilesetFile in an action BUT
    ** These files have to be already loaded as a resource
    ** The file arguments to these actions are hardcoded!?!?
    ** I think this means I will have to create a huge conditional tree for each level name that loads the correct map and tileset theme?
    ** This is what I currently have to do for music files too sigh
  • My spawn points are vertically dynamic, so I need to move the TileMaps to lay correctly on top of the collision platforms
    ** I already have a way to bound the camera, so I think I can use similar logic to map the position of the TileMap
    ** It looks like there are actions to modify the position of the TileMap object, so I think I’m good here
  • My levels sometimes have “hidden” areas, so I envisioned using a separate layer for those areas
    ** The DisplayMode of a TileMap is mutable via actions, but it’s confusing
    ** I think I will need to likely hide the “secrets” on the TMX when saving
    ** Then make the TileMap default to “all” for DisplayMode, and switch it to “visible” when they player object is obscured?

I’ve been anticipating being able to paint my levels with TileMaps, but as you can see above there are lots of technical challenges to do it efficiently. I think it looks like I can get it down to:
1 Atlas Image per Theme
1 TileSet JSON file per Theme
1 TMX Level JSON file per Level
2 layers per TMX level
Which results in:
1 TileMap object per Theme?
A big conditional block to select the correct TileMap object based on the theme name string
A huge conditional block that sets the level resource on the selected TileMap object based on the level name string

That seems like “oof”, but doable.
If anyone else is thinking about how to do this right, or has comments on my approach please let me know.
Thanks in Advance!

1 Like