Create a Flash game like Talesworth – Step 2: Line of sight

As you can see if you play Talesworth, your hero will keep on running according to the same rules “run straight until you hit a wall, then turn right by 90° until you find a walkable tile, and keep on running” unless he sees a loot.

If the hero sees a loot, he changes the way he’s walking to grab the loot.

In this second part I’ll focus on the line of sight on a tile based level.

The concept is simple: the hero can see in the four directions until a wall (or some other solid object) blocks his line of sight.

This can be easily done with a couple (four, to tell the truth) of while loops, looking for the closest wall on each direction.

The following is the first script you found at step 1, the one you are moving the hero with arrow keys, with a graphical representation of the line of sight.

And this is the result:

Move the hero with arrow keys and see his line of sight change in real time.

No need to download anything, just cut/paste this script on the file you found in the previous example.

  • Hi Emanuele, I’d like to get in contact with you. Could you please send me a email with a way I can reach you please.


  • James

    Hey Emanuele,

    First of all, great tutorial series, I’m a regular visitor of your site and you have good knowledge about these things and more importantly you know how to explain it…

    I have seen you are master of games building in Flash. I am developing a simple keppy-uppy game in AS2.

    Something like this:

    I have my player designed, I am just having problems with the ball and player interaction, there is some physics/maths involved and I’m not very good at both of them.

    Can you do a little demo for me? I know its piece of cake for you. May be you have done something similar before.
    Just let me know whatever resources/help/tutorial you can provide. Any kind of help will be highly appreciated.


  • Quintus Kilsdonk

    Hey emanuele,

    I made a game with your tutorials:
    -car game
    -ball collision
    -artillery game

    here it is:

    thank you for your tutorials :D

  • Ok waiting for step 3

  • Pingback: Create a Flash game like Talesworth – Step 3: The loot - Emanuele Feronato()

  • Mari

    I’m really sorry to bother you…

    When I play the demo memory game ( I can hear the sounds. However, when I play the downloaded version the sound does not play. (I did download swfobject and place it inside of the game file). Would you be so kind as to tell me what did I do wrong and how can I rectify it?

    Thank you so much!!


  • RPG

    Hi Emanuele,
    Thank you so much for the tutorial.