# Thread: Confusing - Depth on tile based games

1. ## Confusing - Depth on tile based games

Hi all, I'm currently in the process of making a Zelda-style test game using the tutorials found on Tonypa's website. However, I have run into some very confusing problems which have stumped me. I did come up with a couple of pretty "hacky" solutions to these problems but none which seem to be very efficient.

It's quite hard for me to explain but here I will try using images I took from an emulator (I own the actual game so it is legal )

As you can see, parts of the tiles are solid, non-solid and some allow the hero to move behind the building.

I would also like to know this:

I know the 2D zelda games uses tile based system, but how do they work with objects like these?

Objects like the grass which can be cut, or picked up etc. One solution is to have another timeline layer, and use placeable movieclips but there must be a more efficient method?

So 2 questions really, but any help on either is greatly appreciated

(Sorry for any bad english, it is not a first language of mine)

2. Simply place the house on a different layer above zelda. In the house MC place a section to where he can't walk that way the house can somewhat overlap.

For walking under sections you could probably use masks. Or do the same thing as the house and place that above it.

Tiles. Create a tile object, and have a layer dedicated to tiles on the 'ground' plane. When you pick one up execute a function, swap out tiles and then place a tile in zelda's hand. Pretty simple really.

Now I told you the logic behind how you can do it. Actually doing it is the fun part which I'm not going to do because I have homework! Ha! If you have a question feel free to ask!

3. ??_?? you didnt read the complete set of tutorials there, did you? cause what you are asking is already explained in the tutorials, far better than i can say here....but still. when using tiles, dont think "layer", but depths is a different thing...what comes in handy in here is swapDepths() function... all the tiles in a tile based game has some properties as you might have read already, like walkable, non-walkable, etc, and also they have depths...so when you want to go behind a object, you simply swap the depth with that tile. I suggest you read the isometric tutorials on the site to get a better understanding.

Also, all the tiles in the game are actually objects/movieclips in themselves, they are not just generated in code but are attached from the library, so they can behave as objects separately too. But in this case you should add another property to the prototypes, something like "pickable=true", then whenever a player is on the objects tile, and he does the action to pick it up(like press a key), just remove that tile(from the tile array, and repopulate it), and add a variable against the item in the palyers inventory. i know what i am saying might be a bit hard to understand as i cannot give any proper examples, but trust me, if you go through all the tutorials at tonypa, you will get all your answers.

4. Thanks guys! I will give it a try soon.

5. Originally Posted by ZumoWrestler
Simply place the house on a different layer above zelda. In the house MC place a section to where he can't walk that way the house can somewhat overlap.

For walking under sections you could probably use masks. Or do the same thing as the house and place that above it.

Tiles. Create a tile object, and have a layer dedicated to tiles on the 'ground' plane. When you pick one up execute a function, swap out tiles and then place a tile in zelda's hand. Pretty simple really.

Now I told you the logic behind how you can do it. Actually doing it is the fun part which I'm not going to do because I have homework! Ha! If you have a question feel free to ask!
That sounds like a horrible idea. You want a system that you can use for every game and that's fast. Swapdepth is probably a pretty good solution as bluemagica said if you are using movieclips.