Results 1 to 17 of 17

Thread: Walls, Collisions, Mazes... ?

  1. #1

    Thread Starter
    Hyperactive Member $uper-$tar's Avatar
    Join Date
    Aug 2001
    Location
    Usa
    Posts
    372

    Unhappy Walls, Collisions, Mazes... ?

    Umm... I need help.. alot of help.

    I wanted to make a simple maze thing, were the user can move through a maze, but not going through the walls...

    How can I make this, and How can I make the walls.

    This thing is frying my brain, I need help

    ~$uper-$tar


    If you have any tutorials or know of any that learn to make a 2d maze or something that can help... and that it is easy to learn from with out the complex ways... thanks

  2. #2
    Lively Member
    Join Date
    Aug 1999
    Posts
    89
    Hi

    How I would make a maze is by storing the maze in an array.

    X columns
    0 1 2 3 4 5 6 7 8 9 or however long the maze is
    1
    y 2
    3
    c 4
    o 5
    l 6
    u 7
    m8
    n 9

    Then filling the array with either 1's or 0's. A zero in the certain spot would mean you can walk there, and a 1 could be a wall

    so the array could look like this, NOTE that a wall should be placed around the border, so you can't just walk off into nowhere, and using a 2 for the start, so you can place the person in a maze, and a 3 for the end

    X columns
    0 1 2 3 4 5 6 7 8 9 or however long the maze is
    1 1 1 1 1 1 1 1 1 1
    y 2 1 2 0 0 0 1 0 1 1
    3 1 0 1 1 0 1 0 0 1
    c 4 1 0 0 0 0 1 1 0 1
    o 5 1 0 1 1 1 0 0 0 1
    l 6 1 0 0 0 0 0 1 1 1
    u 7 1 0 1 1 1 1 0 3 1
    m8 1 0 0 0 0 0 0 1 1
    n 9 1 1 1 1 1 1 1 1 1

    Then you move through the maze by just adjusting the array +1 or -1 to move left and right in the x column, or +1, -1 in the y column to move up or down.

    Hope this helps

  3. #3

    Thread Starter
    Hyperactive Member $uper-$tar's Avatar
    Join Date
    Aug 2001
    Location
    Usa
    Posts
    372

    Unhappy Hrmm...

    I have no clure how to do that... could I ask for a small design so I can understand it more clearer?

    ~$uper-$tar

  4. #4
    vshammas
    Guest
    hey,
    i also need this info for an rpg. any concrete examples would be useful, i know how to do it theoretically, but i need the code! just something to get me started. thanks!
    victor


    btw, i know that there is a tutorial at http://markbutler.8m.com where it shows how to create a maze, but it is randomly created. how can i define a map without having it be random? thanks.

  5. #5

    Thread Starter
    Hyperactive Member $uper-$tar's Avatar
    Join Date
    Aug 2001
    Location
    Usa
    Posts
    372

    Its very good...

    Only bad part is, they picture is slow compared to where the guy is. Though very easy to understand.

    Thanks

    ~$uper-$tar

  6. #6
    vshammas
    Guest
    that was a great maze tutorial! thanks, it really helped. i have one quick ? though.

    in the timer1 where you are actually drawing out the graphics there is the following loops

    For x = 1 To 10
    For y = 1 To 10
    If MazeArray(x, y) = 0 Then ' draw white box
    color = RGB(255, 255, 255)
    ElseIf MazeArray(x, y) = 1 Then ' draw black box
    color = RGB(0, 0, 0)
    ElseIf MazeArray(x, y) = 2 Then ' draw red box
    color = RGB(200, 0, 0)
    ElseIf MazeArray(x, y) = 3 Then ' draw blue box
    color = RGB(0, 0, 200)
    End If
    Line (x * BOX_WIDTH, y * BOX_HEIGHT)-(x * BOX_WIDTH + BOX_WIDTH, y * BOX_HEIGHT + BOX_HEIGHT), color, BF
    Next
    Next


    Specifically i have a question about this line:

    Line (x * BOX_WIDTH, y * BOX_HEIGHT)-(x * BOX_WIDTH + BOX_WIDTH, y * BOX_HEIGHT + BOX_HEIGHT), color, BF


    what is it that you are doing? what is BF and why are you multiplying the x coordinates with the width and height? thanks!

    also, if i know want to use pictures (tiles) instead of blocks of colour, i have heard that i have to use something called BitBLT. what is this and is there a good tutorial?

  7. #7
    Lively Member
    Join Date
    Aug 1999
    Posts
    89
    Hi

    The line:
    Line (x * BOX_WIDTH, y * BOX_HEIGHT)-(x * BOX_WIDTH + BOX_WIDTH, y * BOX_HEIGHT + BOX_HEIGHT), color, BF

    this is used for drawing the colored boxes you see, BF means
    B = Make a Box,
    F = Fill box with the color

    You could omit the F, and then the box would just be drawn and not filled with the color.

    Line(x1, y1)-(x2, y2), color, (Box and or fill)

    x1 = x * BOX_WIDTH
    x2 = (x * BOX_WIDTH) + BOX_WIDTH
    y1 = y * BOX_HEIGHT
    y2 = (y * BOX_HEIGHT) + BOX_HEIGHT

    okay I'll show you an example then I think you'll see why those lines are like that

    we want to draw a box for MazeArray(0,0) so the very first one

    so:

    x1 = (0) * BOX_WIDTH = 0
    x2 = ((0) * BOX_WIDTH) + BOX_WIDTH = BOX_WIDTH
    y1 = (0) * BOX_HEIGHT = 0
    y2 = ((0) * BOX_HEIGHT) + BOX_HEIGHT = BOX_HEIGHT

    so after this first step
    we have a box in the cordinates 0-BOX-WIDTH, and then 0-BOX_HEIGHT

    so now if we wanted to draw the next box in the MazeArray
    which would be MazeArray(0,1)

    x1 = (0) * BOX_WIDTH = 0
    x2 = ((0) * BOX_WIDTH) + BOX_WIDTH = BOX_WIDTH
    y1 = (1) * BOX_HEIGHT = BOX_HEIGHT
    y2 = ((1) * BOX_HEIGHT) + BOX_HEIGHT = BOX_HEIGHT * 2

    so in effect the box is directly below the first box

    if instead you used the equation

    x1 = x
    x2 = x + BOX_WIDTH
    y1 = y
    y2 = y + BOX_HEIGHT

    we would only be moving 1 pixel over every time we drew a new box, so we need to move over the box's width or height everytime
    we draw another box

    I hope that helps

    as for BitBlt, I've never used it before, I learned DirectDraw instead,

    BitBlt is a way to take the images you've drawn and be able to display them into your project. Its sorta of like the Line command cept that you aren't confined to lines, but instead you use images

    but www.planet-source-code.com should have something on BitBlt for a tutorial

  8. #8
    vshammas
    Guest
    Great, thanks. i understand it now. i found a bitBLT/tile based game tutorial on this website in case anyone else is interested as well:

    http://fox.acky.net/vb/english/codin...ial/index.html

    merry christmas

  9. #9

    Thread Starter
    Hyperactive Member $uper-$tar's Avatar
    Join Date
    Aug 2001
    Location
    Usa
    Posts
    372

    Pictures instead of Boxes?

    How would you change the Box to a image?

    ~$uper-$tar

  10. #10

    Thread Starter
    Hyperactive Member $uper-$tar's Avatar
    Join Date
    Aug 2001
    Location
    Usa
    Posts
    372

    Maybe what I mean is...

    How could you make the white boxs to a picture...
    How could you make the black boxs to a picture...
    How could you make the guy to a picture...


    ~$uper-$tar

  11. #11
    vshammas
    Guest
    the way i understood it is that you have to work with more complicated code using certain API calls (?, is that what you call it?). go to that tutorial website mentioned previously and look through all the posts. i don't think you can just replace the balls by typing in the path of a picture...

  12. #12

    Thread Starter
    Hyperactive Member $uper-$tar's Avatar
    Join Date
    Aug 2001
    Location
    Usa
    Posts
    372

    Unhappy yeah

    thats what i thought after tying other ways... i thought maybe I could try the path of the picture...

    Btw, Merry Christmas

    ~$uper-$tar

  13. #13
    vshammas
    Guest
    merry christmas!

    i found a few good tutorials on the net, go to www.planet-source-code.com and search for tutorials under visual basic.

  14. #14

    Thread Starter
    Hyperactive Member $uper-$tar's Avatar
    Join Date
    Aug 2001
    Location
    Usa
    Posts
    372

    Talking Links and Tutorials

    Here are some I will be reading over the long night

    BitBlt Tutorial-
    http://rookscape.com/vbgaming/GBeebe/bitblt.php

    Tile Tutorial Part 1-
    http://www.vbexplorer.com/tiletutor.asp

    Tile Tutorial Part 2-
    http://www.vbexplorer.com/tiletutor2.asp

    The BitBlt API-
    http://www.vbexplorer.com/library/bitbltprimer.htm

    VB Role Playing Game Tutorial-
    http://rookscape.com/vbgaming/vbrpgtut/vbrpgtut.php

    Hole bunch of tutorials-
    http://rookscape.com/vbgaming/tutorials.php

    My gift from me to you all

    ~$uper-$tar

  15. #15
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    I have one too if anyone is interested:

    http://vbden.tripod.com/articles/invmask.htm
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  16. #16

    Thread Starter
    Hyperactive Member $uper-$tar's Avatar
    Join Date
    Aug 2001
    Location
    Usa
    Posts
    372

    Talking I am always intrested

    LoL, i will master this in... a day or too lol. So far I got like 50 pages on this stuff

    ~$uper-$tar

  17. #17
    vshammas
    Guest
    thanks !

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