So, I'm creating a 2d, top down, sprite based (tiled) game, and right now I'm working on maps (well, a map editor at the moment, but it will be creating my maps, so basically the same thing).

The scenario

So, I'm thinking about efficiency and creating a map in pieces. In each piece, I plan on having 'layers'. Basically, I plan on rendering it down to a 'below hero' level, and an 'above hero' level, with the hero rendered in between obviously. There will likely also be a 'on level with hero' layer, but I'm not quite there yet. Not even worrying about events or interaction yet. Just looking to get a hero on the screen.

Now for movement, I obviously need to know what tiles can be moved and in what direction. My plan at the moment is each tile getting 8 bits (4 'can enter in direction' bits, 4 'can leave in direction'). This will allow me to limit movement and even allow one way directional movement.

The dilemma

This works great for a lot of scenarios. It will allow me to store a map in essentially 3 layers, a string, and gives me flexibility going forward. However, I can't create maps that themselves have layers. A good example is a bridge where the user can go under or over the bridge without invalid moves being allowed. I can't create a platform and allow movement underneath. These are things I would like to be able to include in my game.

My idea

In theory, I could allow multiple hero layers and then allow multiple sets of 'below' and 'above' layers (or sandwich layers). But this complicates my system, and makes movement between maps potentially tricky (If the hero is on the third layer at the edge of a map, but that corresponds to the second layer on the other map, how can I allow or disallow movement).

My question

Is there a better way to manage multiple maps with multiple levels like this where a users level may be 'connected' on different levels on different maps?

Or even...

Am I doing this the hard way? Is there a more standard way to handle top-down 2d tiled maps that I am just not aware of?

Things to note or that might be helpful

  • This will be done in Javascript (transferred around in JSON)
  • State will need to be transferred quickly, so a map-id and x/y/direction should be enough to get me a boolean 'can move' value
  • Maps will not be standard sized (though they will be in a certain number of tiles)
  • Making an editor tool so that I can have others help, so something that I can create in a tool would be helpful
  • 'Teleportation' locations will likely need to exist to get into building maps and to and from different map sets (which will not necessarily be connected), but have not been created yet (lumping in with events at the moment).

1 Answer 1


'below hero' level, and an 'above hero'

Why do they layers have to be relevant to the Hero? Shouldn't it be the opposite as in the hero has a current level they are on? If the hero is on level 1 then all levels above level 1 are drawn after or on top of the hero. This works for any number of level so you are not restricted to 2 levels. You can have the player keep track of what level they are on and alter it with basic collision detection. A wall to wall series of tiles on the top of a stair case can set the player to layer 1 where as a similar thing could set the player to level 0 at the bottom of the stairs.

You would only do collision checking for the current layer so in the case of going under the bridge you could walk right under it if there was no obstruction on layer 0 while all above layers would be rendered only.

  • \$\begingroup\$ You know, I'd originally switched away from this approach because of the editor, but I think you're right, this is going to be the most sensible. I think I'll just do layers in the editor, grouped by level, and do level based movement space. Thanks \$\endgroup\$ Commented Nov 30, 2011 at 4:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .