Flash prototype: walking on disappearing tiles

I remember an old c64 game (and some flash and javascript remakes) where you had to walk over all tiles in a stage, never walking on the same tile twice, because as you leave a tile, it disappears.

In this far-from-being-finished prototype, I took some pieces of code I found in a tutorial published on gotoandplay and coded this prototype.

Try to walk over all tiles, without falling down.

Cursor keys to move.

The whole actionscript is on the 1st frame

Some comments to the code:

Lines 95-103 (yes, it’s better to begin from the end): I define the map, in this case a 7*7 array. “1” means there is a tile on the floor, “0” means there is no floor, and you will fall down if you step over it.

Lines 83-94: Time to draw the map, attaching the same movieclip (a 20*20 red square) when I find a “1” in the map array.

Lines 1-13: Initializing the game and creating some variables, most of all about the main sprite (the 20*20 green square, the sprite you control)

Lines 15-36: Checking if an arrow key is pressed and if the sprite was already moving, then calculating new sprite’s position according to the key pressed.

Lines 37-61: Routine that moves the main sprite and makes the floor disappear behind it

Lines 62-67: Checking if the sprite is on a tile or not

Lines 69-80: If the sprite is dead, because he has not floor under its feet, re-initialize the game and start again.

That’s all at the moment, download the source code and give me feedback while I unleash some more ideas…

  • Joe

    This is great and all.
    But, I was wondering, would there be a way to make more levels with like bigger maps and such?

  • Krut @ Joe

    Joe, one way could be to make some squares black, being impassable, getting more and more. You’d have to be creative to make them successful and/or hard.

  • Mousey

    Will there be another tutorial on how to add more levels as i’m new to action script?

    and i think the tutorial i fab !

    thanks Mousey

  • Emanuele Feronato

    Sure it will!!!!

  • eblup


    do you put this in a flash file or no is it a move clip do you need to draw anything explain it geesis christ u moreon

  • chris

    i don’t get what you have to do.
    i put the code in actions for the first frame and when i test movie nothing happens.

  • Its simple to make although i noticed its not all said it the tutorial,

    First create a new document in flash with the dimentions:
    140 by 140 and frame rate set to 40fps

    Second you need 2 create 2 movie clips

    one called my tile, make this a red square approx 19px by 19px. then in the library right click it and press export for action script, with the identifer set to my tile.

    The next movie clip is called item make this the same as before but make it another colour (e.g. green) and when you set up the linkage set the identifer to item.

    Last add the action script to the frame and it should work!

  • omgwdfbbq


    do you put this in a flash file or no is it a move clip do you need to draw anything explain it geesis christ u moreon”

    How old are you? I thought this tutorial was fine for someone with an IQ above 60…

  • Dan

    Pretty awesome, especially considering how small the code is! I’m new to flash but not to programming, and this is already giving me some rad ideas to work on…

    Was the C64 game reckless rufus by any chance?

  • Emanuele Feronato

    Yeah, it was a good game, long live commodore64

  • Hi,
    I found your blog via google by accident and have to admit that youve a really interesting blog :-)
    Just saved your feed in my reader, have a nice day :)

  • andrew

    Yea i’ll haft to try it. It’s sad thet im only 8 years old and i’m prity good at it.A’ll try that today. Ok

  • Chazz

    Dude I put the code in my first frame but nothing happens..

  • Justice

    Also you could add holes already there, or powerups such as a bomb that destroys a 3×3 square. Perhaps you have to be a certain colour when touching certain tiles in later levels so you have to go to the tile that has the next colour first before you can destroy tiles of that colour

  • robert

    Hey im following the security tutorial how would i make a health pack dissipere
    I was guessing that it would be like this code

  • Des

    Hi, excuse me for the dump question, but what code do you write when you want to remove the map – I mean, go to an end frame for the game or something like this. Just how to get rid of it, if you want to load something else.
    I am newbie with Action Script and I will appreciate your help.

  • Ruiqi

    For an end frame, in the first frame or the frame the game is on, put stop(); to go to the next level or to the end page, put gotoAndStop(whatever frame the next level or end page is); somewhere but i don’t really know where.

  • how would i make it go to the next frame once the green square is on the last red square?

  • Jamis

    Hey, did you know your site is serving out malicious JS code?

    Your site is on

    2009/04/07_00:00 http://www.emanueleferonato.com/2006/11/26/flash-prototype-walking-on-disappearing-tiles/ webx31.aruba.it compromised site/redirects to Mebroot itpuntoit snc, Emanuele info@itpuntoit.it

  • This was great.i’m a beginner so it was littledifficult.