Tiled game best practices: Example Pacman

I’m used to making 3D games but not 2D tile based games. I’d be very grateful if some more experienced Tiled users, or old-school programmers, could answer a few simple questions by way of example to ensure I start on the right track. I’ll use Pacman as the example.

  1. It seems that there should be one layer which contains the static, collidable tiles i.e. the walls. Imagine there were no dots or power-pills to collect but just black corridors to walk through. Should the black tiles representing empty corridor normally be (a) in the same layer and flagged with a property (or index range perhaps) or (b) in a separate non-collidable layer? If (a) they I each tile would need a “solid/collidable” property. If (b) then there are empty tiles in the collision layer.

  2. Should the layer containing the dynamic tiles (dots, power-pills) be an object layer containing tiles, or would a tile layer be more appropriate?

  3. Is the runtime tilemap data usually static? By static I mean constant and unchanging. Say for example the player collects a load of dots and a power pill from the object layer, should these be actually removed from the map layer data at runtime (say in the TMX library structs), or would the tile/object layer be used at load time to create a set of game objects to represent the dots and pills which would be destroyed as collected? I guess the latter approach would mean that the .tmx files only need to loaded once at startup, and not cloned.

  4. Is it normal to have a single tileset image file containing images for both tiles and sprites, or do games normally have image file(s) for tiles and separate ones for sprites?

Many thanks!

I’m afraid the answer to all your questions is that every option is a valid approach. I’ll try to give some advice, but it all depends.

  1. Using a separate collidable layer makes sense when you have lots of different tiles, because that avoids managing the “solid” custom tile properties for all your tiles. In contrast, using a custom property avoids the need to switch between those layers and needing to use the eraser tool in case you need something gone in the collidable layer.

  2. If you want all your objects to align to the grid and generally don’t have multiple objects in the same spot, you probably want a tile layer. In contrast, an object layer allows you to place objects with pixel precision and they can overlap without the need to create multiple layers for this.

  3. I’ve seen both approaches, and often you’d use a mix. Especially if a Tiled map renderer is already part of your framework, you’re more likely to end up modifying the data during the game. In other cases I think you’re more likely to convert and discard data since this can make it easier to add behavior and animation.

  4. It’s up to you. If you can fit all your graphics on a single tileset, I don’t see a reason not to do this. But it is probably more “normal” to have more graphics than would fit in a single tileset. Also, with Tiled you currently need to use different tilesets if you want to use tiles of different sizes (unless they are all individual images).

1 Like