Create a Flash game like Talesworth – Step 4: One-way doors

In this 4th step we’ll cover one-way doors.

One-way doors are tiles the hero can walk only once, before they become unwalkable.

First, let me show you a fix to the script shown in step 3.

In the example, the loot disappears when the hero sees it, he does not have to touch it. Since I make the loot disappear setting loot_placed variable to false, now I set it that way only when the hero is on the same cell where the loot is placed.

And now, let’s talk about one-way doors.

When you have a lot of items on your map, such as doors, keys, enemies, traps and so on, I suggest you to create various layers of the same map. This will make your life easier and will allow you to add more and more stuff on the map without rewriting that much code.

That’s why I created anoter array, of the same size as map array, called itm. A value of 1 in itm array means there is an one-way door.

When the hero walks on a tile with an one-way door, the tile is set as unwalkable setting to 1 the value in the map array.

This is the source code:

And this is the result:

Try to place loots to make the hero walk on the pink square, and see what happens when the square turns red.

Download the source code.

  • Alexandre Colella

    Hi Emanuelle! I’m from Brazil and I’m looking your blog!
    It’s a great form to learn Flash.
    I am beginner in Flash game develop and I’m learning a lot with you.
    Thanks a lot!!

  • anlik

    Hi Emanuelle! Please visite:

    http://www.kongregate.com/games/athenaBianBian/3d-super-girl

    Can you publish a post about how to do this game?

  • Awsome

    Can you continue this tutorial.
    Like adding gates and keys and multiple lvls?