Create a Flash game like Talesworth – Step 3: The loot

One of the main features of Talesworth is the hero keeps running according to his rules until he spots a loot. Then he changes its way to grab the loot. In part 1 I showed you how to make the hero walk like in the original game, and in part 2 I introduced the line of sight.

Now it’s time to place the loot and make the hero change his way. Greedy.

First, I have to say the movement routine I showed in step 1 is buggy. Not that buggy, it’s just in some circumstances the hero does not behave like in the original game.

So I changed the script. Now it works this way:

* The hero walk straight until he finds a wall
* He tries to turn right
* If he can’t turn right, he tries to turn left
* If he can’t turn left, he returns back

As for the loot, I scan in the four directions as showed in step 2, then if I find a loot in one direction, I simply set the hero direction according to loot position.

In this new script I simply created a new movieclip called loot_mc and made it work this way:

* You can only place the loot on a walkable tile (marked with 2)
* You can only place ONE loot
* Once you placed a lot, you can’t move it until the hero sees it
* When the hero sees the loot, he changes his direction

A bit different from the original game at the moment, but at this time I just want to create the loot engine. And it works… in real time… here it is the script:

And this is the result:

Play placing the loot with the mouse clicking on a tile in hero’s line of sight, and see how he changes direction. Then place the loot again.

Download the source code.