Dungeon Raid iPhone game engine made with Flash and AS3

An iPhone game which I enjoyed a lot last year, a great twist in the “match three” genre, was Dungeon Raid.

Tracing a path and matching tiles you will be able to collect treasures, buy and upgrade weapons and defeat monsters.

In this post I am going to cover the part which traces a path along tiles. While it may seem easy, there are a couple of interesting things to consider:

1) Your path can be traced in diagonal, and this means you have to define hot spots on the tiles which must be smaller than the tile itself, or you surely touch adjacent horizontal and vertical tiles before you touch diagonal ones.

2) You can backtrack through the path, but you can’t walk over already other previously selected tiles. This will require a vector to be used as a stack to manage backtracking.

I made a fully commented script, where Tile and Path are the two movieclips representing respectively the tile (frame 1: unselected, frame 2: selected) and the path (frame 1 to 8: west, north-west, north, north-east and so on in clockwise order).

The darker circle inside tiles is the hot spot.

Enjoy the result:

Select tiles and move the mouse to draw a path and eventually backtrack it.

Download the source code

  • Bruno

    There seems to be a slightly problem.

    Here is a pic:

    I dont know exactly how I did this, but I was trying to cross paths.

  • Bojan

    Found a bug, if you select few squares and then stop in last (for example, mouse button is down all the time) and move a mouse in that square a bit then release a mouse and game will not clear squares, they stay selected.

    Do you plan part 2 of this tutorial?

  • Bojan

    Edit: You need to go forward and back few times between two or more fields to recreate this bug, it does not show all the time but it can be done pretty often.

  • pp

    seem when i try to make diagonal and longer lines,
    then back tracking then make false back tracking diagonal and released mouse
    then circles is not reset

  • Ervin

    Anyway it’s a very interesting post. Thank you.

  • Husky

    I love this game too,
    Thanks for your sharing.