Page 1 of 1

Using Tiled as a map editor

Posted: Thu May 28, 2020 12:48 pm
by rox_midge
gauauu wrote:
Thu Jan 23, 2020 4:49 pm
I can't speak for this project, but I'm someone who uses and loves Tiled, and would be happy to talk about strategies for making it work for NES with metatiles and palettes. If so, we should branch that out into a different thread.
I'd like to hear more about this, so I thought I'd go ahead and create the thread that gauauu mentioned in this thread!

My project is (tentatively) using 8x8 tile chunks for its map, so having the ability to organize them in something like Tiled would make things a lot simpler.

Re: Using Tiled as a map editor

Posted: Thu May 28, 2020 2:45 pm
by gauauu
First, the main thing to keep in mind is that Tiled's goal is to let you assemble your map tiles into a bigger map. So things outside of this (generating metatiles, palettes etc) are a bit beyond the scope of the core of what Tiled is good for. That said, there are still useful ways of handling these things.

In a couple of my projects, what I've done is create my metatiles outside of Tiled. I've built a really janky tool for doing so, but it lets me define 4x4 metatiles, and associate palette and collision data for each metatile. So for these games, each metatile has palette/attribute information baked in. You can't apply different palettes to the same metatile. My janky tool then spits out a new image of my new "meta-tileset" -- an image that's only used in Tiled for helping me draw maps.

I then draw the maps in Tiled. My build script then reads the Tiled files and turns the map data into data for my rom. So it's stored in rom by metatile ids that Tiled uses. The build script also processes my metatile defintions, so they're available in the rom data. At rendering, it reads a metatile id, then looks up the actual tile definitions for it. Palettes/Attributes are easy, because I'm using 4x4 metatiles, so I just look up the attribute byte in my metatile definition. For collision checks, I read the metatile id, then look up the collision data for it.

If you want to read more about this, I explain it a little more at https://anguna-dev.blogspot.com/2019/10 ... eline.html

That all said, since I started this, Tiled has now added some simple support for metatiles in the application itself. I haven't used them, so take this with a grain of salt, but you can create a metatile set by creating a new map, and just drawing tiles into it in groups, arranged into your logical metatiles. Then, when you start creating your "real" map, you can load that first map as the tileset (instead of loading an image as a tileset). When loading it, you can specify the tile size, and then you can draw with those metatiles. In this case, the big question becomes "how do you handle palettes"? I'm not sure the answer to this question here.

Re: Using Tiled as a map editor

Posted: Thu May 28, 2020 4:07 pm
by tokumaru
gauauu wrote:
Thu May 28, 2020 2:45 pm
you can create a metatile set by creating a new map, and just drawing tiles into it in groups, arranged into your logical metatiles. Then, when you start creating your "real" map, you can load that first map as the tileset (instead of loading an image as a tileset). When loading it, you can specify the tile size, and then you can draw with those metatiles.
Interesting! Can you do this recursively? I mean, can you have metatiles made of metatiles made of metatiles and so on?

Re: Using Tiled as a map editor

Posted: Thu May 28, 2020 9:25 pm
by turboxray
gauauu wrote:
Thu May 28, 2020 2:45 pm
In this case, the big question becomes "how do you handle palettes"? I'm not sure the answer to this question here.
Either put your palette info in a metablock that exists outside of Tiled, but mirrors what you see in Tiled. Or have an extra layer hold the palette "number". Since you can export any layer as a CSV, it's trivial to do whatever you want with that data. The first approach is the easiest though.

Re: Using Tiled as a map editor

Posted: Fri May 29, 2020 9:19 am
by gauauu
tokumaru wrote:
Thu May 28, 2020 4:07 pm
gauauu wrote:
Thu May 28, 2020 2:45 pm
you can create a metatile set by creating a new map, and just drawing tiles into it in groups, arranged into your logical metatiles. Then, when you start creating your "real" map, you can load that first map as the tileset (instead of loading an image as a tileset). When loading it, you can specify the tile size, and then you can draw with those metatiles.
Interesting! Can you do this recursively? I mean, can you have metatiles made of metatiles made of metatiles and so on?
No idea. Would be fun to try tough.

Re: Using Tiled as a map editor

Posted: Fri May 29, 2020 5:22 pm
by tepples
Blaster Master uses 64x64-pixel metatiles made of 32x32-pixel metatiles, which are in turn made of 16x16-pixel metatiles, which are made of 8x8-pixel tiles.

Re: Using Tiled as a map editor

Posted: Fri May 29, 2020 7:40 pm
by rox_midge
gauauu wrote:
Thu May 28, 2020 2:45 pm
That all said, since I started this, Tiled has now added some simple support for metatiles in the application itself.
By "now added" you mean "literally started landing in snapshots on Wednesday." That's serendipity!

I've just spent a few minutes futzing about with it, and this feature is absolutely golden, IMO. I'm nowhere near the point of actually putting together a real map - much less anything approaching an actual tileset - but I can literally have one tileset based off my source bitmaps, which is used to put together my 64x64 pixel chunks, which is then used as a tileset for my world map. It automatically updates as the underlying sources are tweaked!

Now if I could just get the @&$# attribute bytes to update properly when I scroll...