A Flash Developer Resource Site

Page 1 of 5 12345 LastLast
Results 1 to 20 of 97

Thread: how to detect maze walls?

  1. #1
    Junior Member
    Join Date
    Sep 2000
    Posts
    15

    Angry

    I'm working in a very simple game, i have an ant that has to walk inside a maze, i can make the ant not go out of the maze's walls, but how can i prevent the ant to walk over the inside walls of the maze.

    Thanks.

  2. #2
    Senior Member Mad-Sci's Avatar
    Join Date
    Mar 2000
    Posts
    2,756
    I think this is a good topic to get you started:
    http://www.flashkit.com/board/showth...threadid=10833
    Mad_sci

  3. #3
    Senior Member
    Join Date
    Jun 2000
    Posts
    435
    WOW the TBW thread; I remember that was a good one. Hay Mad-Sci, we should talk tiles I got sum new ideas, as I would assume you do to?

    Hehehe Tiles Good! Jaime Garate if you have questions about any thing in that Thread, just ask?

  4. #4
    Junior Member
    Join Date
    Sep 2000
    Posts
    15

    Lightbulb More help

    Ok, guys i read the thread, i think i learned a couple of things, but some stuff is not clear to me, after i create all this tiles info (call it arrays), how can i use it in my programming?

    Thanks,
    JGarate

  5. #5
    Senior Member Mad-Sci's Avatar
    Join Date
    Mar 2000
    Posts
    2,756
    Jaime, ok this is not easy you should know this I hope that FlashCat, Xentor and Ilumin8d will help here as well. Meanwhile some more stuff to read
    http://www.geocities.com/SiliconVall...TileBased.html

    FEW QUESTION BEFORE WE BEGIN:
    =============================
    1. When you move the mouse what step do you use ?
    2. What is the size of you mouse MC ? Width and Height
    3. What is the size of you stage.
    4. How do you move the mouse ? what I mean here is when you release the button does it stop?

    Give me some answers to that questions and we can set up your map.

    O BTW are you using F4 of F5 i can help with F4. for F5 you can ask the other guys.
    Mad_sci

    pS ok guys lets make this as simple as mouse moving in a maze .

    Mad_sci
    [Edited by Mad-Sci on 09-11-2000 at 08:42 PM]

  6. #6
    Senior Member
    Join Date
    Jun 2000
    Posts
    435
    Hehehe your so funy Mad-Sci,

    Jaime Garate don’t forget the all mighty TILE? Yes its very important to know what size of tile you want to work with. It can affect graphics, game play, and your coding work.

    And on a personal note try to do it with Flash 5 if you can, it will make a lot of the little coding head panes go away. But on the other hand it’s a lot more to work with!

    Good luck, and don’t be afraid to ask?

  7. #7
    Junior Member
    Join Date
    Sep 2000
    Posts
    15

    Angry How to detect maze walls.

    First of all thanks guys for your big help, here the answers to your questions, in the meantime i'm studying the materials you recommend me.

    1. When you move the mouse what step do you use ? the game starts wiht 10, but the user can select from 1 to 30.
    2. What is the size of you mouse MC ? Width and Height: W=40, H=32
    3. What is the size of you stage. : W=550, H=400
    4. How do you move the mouse ? what I mean here is when you release the button does it stop? i move it with the arrow keys in my kbrd, yes, it stops when i release the key.
    Right now my maze is a graphic symbol inside of a MC.

    I've been programming for many years, but this is the first time i decided to do a game, i've spent about 120 hrs on this project and feel very proud of it (is my little child right now) and actually i'm learning a lot in the process.

    i'm agree with FlashCat, this is really fun even with your clothes on!

  8. #8
    Senior Member
    Join Date
    Jun 2000
    Posts
    435
    Jaime Garate, and cloths can even be optional. Hehehe, well back from where ever that was.
    I think it might help you out; to do some field research… find out what you think makes a game fun, challenging, what is the replay value of a game, so on? Get a good foundation so to not only make a game but also make a grate game.

    PS. Pay very close attention to UI (User Interface) this can make or brake most games!

  9. #9
    Senior Member Mad-Sci's Avatar
    Join Date
    Mar 2000
    Posts
    2,756
    Hey FlashCat I left you a msg here on the board a bit down.

    Now Jaime, we have to do some changes here is what I would recommend if its not to much of a pain to do. Actually we can do the script from scratch. Now open new movie not yours and Modify to

    Stage make it 300/300
    show the grid 10 px.
    create a blue sqr with size 10/10 this will be our tile.
    Paste your ant on the stage as a MC 10/10 which you can move with a fixed step of 10.( did I hear Nintendo ..hehe)
    From here we have to deside which strategie to use.
    1. to create a look up table in NotePad or
    2. to create a look up table on the fly
    for the seccond read the post "FlashCat..." here on the board a bit down. Ill play with number 2 to optimize the script and will get back to u.
    Mad-sci

  10. #10
    Senior Member
    Join Date
    Jun 2000
    Posts
    435
    Jaime Garate, Mad-Sci, I don’t think its necessary to change any thing? You can use whatever tile size you want, be creative! But do keep in mind that fewer tiles is easer to work with, and your tiles should be derivative of your Game window. The NES uses 8bit, or 16bit tiles that divide evenly into TV resolution of 320x240. The SNES uses 16bit, 32bit. Most computer games use 16bit or 32bit because the monitor resolution is 640x480. Your tiles don’t even have to be square!

    I would also recommend avoiding making characters the same size as your tiles. This helps obscurer the tiles even more to the eyes of your players. You don’t have to do collision detection the sprites art, you can use made up values that work better with the actual tile size.

  11. #11
    Junior Member
    Join Date
    Sep 2000
    Posts
    15

    Angry how to detect maze walls

    ok, i almost got it, but still some more questions:
    - why and how do you use notpad to create the maps/look up tables?
    -what/how is the relation screen pixels vs. tile size?

    i'm still having fun guys, thanks.

    JGarate

  12. #12
    Senior Member Mad-Sci's Avatar
    Join Date
    Mar 2000
    Posts
    2,756
    Now since you move with step of 10 div. _x and _y like -x/10 and _y/10 you can convert the ant screen coords to row and coll relavant to the table. for example:

    with grid of 10 and step of 10 screen coords of x=190 and y=190 will translate to row=19 and coll=19. since your stage is 300/300 this means that you will have 30 rows and 30 coll. now there is another trick you have to use int function all the time and you can add 0.5 to round up the variables. Now create an obstacle mc 10/10 and paste it on the stage snaped in one grid cell. inside translate obstacles -x and-y using the same trick as above but form a variable like "/heroos_"&row&"_"&coll=1 and pass this to the hero MC.
    when you move the hero use something like that pseudo code.

    my_x=_x
    my_y=_y
    oldX=_x --- remember the last _x
    oldY=_y --- remember the last _y
    onKeyup = my_y=my_y-10
    onkeydown.my _y=my_y+10
    onkeyleft= my_x=my_x-10
    onkeyright my_x=my_x+10
    setvar "row"=my_x/10
    setvar "coll"=my_y/10
    setvariable "pos_hero"=eval("pos_",row,"_",coll)--obstacle
    if pos_hero=1
    my_x=oldX
    my-y=oldY
    end
    setproperty x= my_x
    setproperty y=my_y

    ok I made this on the fly but you can play arround and optimize the code.
    keep in touch.
    Mad_sci


    [Edited by Mad-Sci on 09-13-2000 at 02:43 PM]

  13. #13
    Senior Member
    Join Date
    Jun 2000
    Posts
    435
    Your tiles should divide directly in to the game area. This will allow you to fill the game window from one edge to the other with out any funky cut offs for tiles, or blank space that might make the game look lopsided. Its more for cosmetic reasons but over looking it is very bad game design.

    Notepad, is a text editor. You would us it to build an external map_file.txt that contains your map data to be load in to your flash game. This is used to make your game more robust, giving it the ability to load in the data that sets up the map (graphics) and is referenced for tile collisions.

    I hope that helps?

  14. #14
    Senior Member Mad-Sci's Avatar
    Join Date
    Mar 2000
    Posts
    2,756
    I agree with FlashCat here but since Im a lazy @$$ Im looking for new ways of building the map. otherwize nothing beats the txt variables. here it goes.

    row1="000000000000....00000" --- 30 zeros
    row2="000000010000....00000" --- etc.

    you use counters to get the hero row. and substring to get the hero coll.
    Im right FlashKitty ?
    Mad_sci

  15. #15
    Senior Member
    Join Date
    Jun 2000
    Posts
    435
    I agree a Map.txt is such a powerful addition to any game engine. But in Flash 5 I am hared preset to find a good way to get .txt map files to make sense? When compared to .swf that can host all the data in multiple dimensional Arrays. In order to load that kind of data from .txt you would have to split() it several times in order to reach the right depth… well I am going to eventually test both methods and right up a report for my game, so I will let you know. O can’t forget XML docs could be used to pass map data as well, I will let you know what I learn about this possibility as well.

    The only drawback to small tiles is the large number of them that must be rendered in order to fill the game area.

    Hehehe this is so much fun, it makes you think?

  16. #16
    Junior Member
    Join Date
    Sep 2000
    Posts
    15

    Angry How to detect maze walls.

    After many hours of fun (and a lot of caffeine), think i got it.
    this is my code to move the hero :
    On (Key: <Right>)
    Set Variable: "/ld_x" = /:my_x
    Set Variable: "/ld_y" = /:my_y
    Comment: ++++++++++++++++++++
    Set Variable: "my_x" = my_x+10
    Set Variable: "col" = int((my_x/10)+.5)
    Set Variable: "row" = int((my_y/10)+.5)
    Set Variable: "pos_hero" = eval("obs_"&row&"_"&col)
    If (pos_hero=1)
    Set Variable: "/:my_x" = old_x
    Set Variable: "/:my_y" = old_y
    Else
    Set Property ("/hero_1", X Position) = GetProperty ( "/hero_1",_x)+10
    End If
    End On
    -------------------------------------------------------
    This is the code inside of my wall MC:
    Set Variable: "/:my_row" = (int((GetProperty ("",_y)/10)+.5)-1)
    Set Variable: "/:my_col" = (int((GetProperty ("",_x)/10)+.5)-1)
    Set Variable: "/bs_"&/:my_row&"_"&/:my_col = 1

    ---------------------------------------------------------
    Specs:
    hero size 10/10 (MC)
    wall size 10/10 (MC)
    stage size 300/300
    --------------------------------------------------------
    all i have to do is copy/paste the wall MC to build my maze and the code embeded will create the unique tile location (row,col).
    i'm gonna try this in my real project (you know...the ant game) and let you know if it works.
    Just for the fun , can you explain more about maps.txt and how do you use them inside of your movie/code?
    Many thanks.
    JGarate

  17. #17
    Senior Member Mad-Sci's Avatar
    Join Date
    Mar 2000
    Posts
    2,756
    Cool now keep in mind that the wall mc has one frame code put stop action cuz you realy have to send the variables only once to the hero. Now when I tryed this I noticed that the game slows down in preview mode but this might be for my comp. It was ok when exported as swf but still....keep this in mind. Just let me know how it works for you so we can post some tuts about it. This is not the classical way to do this detection you know. One more thing you can use different wall pictures. seccond you can trigger any effect from a tile once the ant steps on it. ( right now the ant will backoff ). O and I forgot to tell you you have to snap the ant to the grid so it will jump from tile to tile. ;D
    Mad_sci
    PS in the above code I did not see definition like
    my_x=_x
    my_y=_y ( or use getproperty ("/ant",_x) )
    see what I mean.


    [Edited by Mad-Sci on 09-14-2000 at 12:01 PM]

  18. #18
    Senior Member Mad-Sci's Avatar
    Join Date
    Mar 2000
    Posts
    2,756
    I think that the code is a bit messed up here is what I do:

    1. obstacle -- send the variable to ---- hero
    2. the hero MC runs the comparisson of the coords.

    dont send variables to the main time line. ok may be im confused a bit. Ill post an example sat or sun. this is the only free time I have right now unfortunately.
    Mad_sci

  19. #19
    Senior Member
    Join Date
    Jun 2000
    Posts
    435
    Hay Mad-Sci, a tutorial would be a grate idea, we could work together to make a general TBW Q&A with regards to flash game design and even more, for FlashKit’s gaming community.

    Jaime Garate, that sounds grate! But I would recommend passing you tile data to a public location rather then your Player object, so any object can reference it independently. You might not have any other objects now but say you would like to add a second ant, having world data behave as public would make easy access by all objects.

    The idea of a map file is the capability to dynamically load new maps in to your game engine. This will also help you cut down the size of your engine, making it more web friendly.

    Ideally your game engine could load in a map file, read the data to set up the tile graphics and could reference the map file data for functions like collision detection, object placement, adjusting world physics, ext.

    Map files would most commonly be used to divide a game world up in to Levels that could be dynamically loaded as the player completes them.

    I hope this clears things up a bit?

  20. #20
    Senior Member Mad-Sci's Avatar
    Join Date
    Mar 2000
    Posts
    2,756
    Nice catch FlashCat, J send the obstacles loacation variables to an empty MC located on the stage and reference them each time you move the hero. Yea this a good thing to do if you want special effects you can create a 2 MC named special and pass seccond set of variables to it. humm not bad idea at all. Dont forget to loop the public mc.
    Mad_sci


    PS guys I have a small surprise for you.
    you know the MiniMax algorithm..... thats enough for now sat. or sun. will be uploaded. boy o boy so much to do so litle time he he he

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center