Thread: Maze walls???

  1. #1
    goofprogram
    Guest

    Question Maze walls???

    Hi, I'm making a maze game in DOS and was wondering how I could make it so the player can not go through the wall's. The wall's are just the double line character's printed on the screen.

    //These are the Wall's
    printf("%c%c%c%c%c%c%c%c%c%c%c",185,186,187,188,20 0,201,202,203,204,205,206);

    Thanks,

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Player is at x,y position, and is facing in a direction
    chFront = charInFrontOfPlayer(x,y,dir);

    if ( chFront == 185 || /* and the rest */ ) {
    // can't move there
    }

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    43
    I understand all that but one part, how will it get the information to know if there is a wall there or not? Is that the dir thing?

    //[chFront] is [char Front;] right?
    chFront = charInFrontOfPlayer(x,y,dir);
    if ( chFront == 185 || /* and the rest */ )
    { // can't move there }


    Thanks,
    ()(ôô)()© MonKey ware
    Kyle J. R.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Well you start with

    char map[24][80];

    And you store a wall at say
    map[2][5] = 185;

    You print stuff on the screen by printing every char in the map array to the screen in some kind of loop.

    you can then tell from looking at map[y][x], whether there is a wall at say map[y][x+1]

    The directions are coded in north, south, east, west

    Like north from [y][x] is [y-1][x]

    Draw it all out on some squared paper - it should become more obvious then

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    43

    Unhappy

    Yeah, I understand that but how does the computer know where theres a wall with out me having to say "theres a wall at x,y & x,y & x,y... so on."
    ()(ôô)()© MonKey ware
    Kyle J. R.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > "theres a wall at x,y & x,y & x,y... so on."
    Well it's either that, or you write a function which generates some walls for you.

    I mean, you were quite prepared to have a whole bunch of
    printf("%c%c%c%c%c%c%c%c%c%c%c",185,186,187,188,20 0,201,202,203,204,205,206);

  7. #7
    Registered User
    Join Date
    Oct 2001
    Posts
    43
    I can make a function that would put random walls but there would be no space's to have the player move around in, I have no clue how to make it so it's a maze and not just a bunch of the double line character's.

    Thanks,
    ()(ôô)()© MonKey ware
    Kyle J. R.

  8. #8
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,212
    Okay, here's a few snippets of code to get you going:

    Code:
    RTFM

  9. #9
    Registered User
    Join Date
    Oct 2001
    Posts
    43

    Question

    ¿What is that?
    ()(ôô)()© MonKey ware
    Kyle J. R.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Q: Recursion to find all paths of a maze
    By reti in forum C Programming
    Replies: 7
    Last Post: 11-26-2002, 09:28 AM
  2. MAZE.. What a MAzzzzz
    By NANO in forum C++ Programming
    Replies: 4
    Last Post: 05-15-2002, 12:21 PM
  3. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-24-2002, 11:00 PM
  4. Algorithm to walk through a maze.
    By Nutshell in forum C Programming
    Replies: 30
    Last Post: 01-21-2002, 01:54 AM