2d, Top-down map with different levels

Posted by Ktash on Game Development See other posts from Game Development or by Ktash
Published on 2011-11-30T03:40:57Z Indexed on 2011/11/30 10:37 UTC
Read the original article Hit count: 185

Filed under:
|
|
|
|

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).

© Game Development or respective owner

Related posts about 2d

Related posts about architecture