Mazes(urgent!!);

This is a discussion on Mazes(urgent!!); within the Game Programming forums, part of the General Programming Boards category; can somebody help me in making my cursor/player stay inside/between the lines of my maze... can somebody give me a ...

  1. #1
    Oid21
    Guest

    Exclamation Mazes(urgent!!);

    can somebody help me in making my cursor/player stay inside/between the lines of my maze...
    can somebody give me a complete format?
    if not tell me what to do...
    else your suggestions

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Can you show some code?
    If yes, we'll help.
    Else, tough.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    I removed your cross post, please don't do it again. Also, "urgent" in your title is bound to annoy a few people. May I suggest you read the rules before posting.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    6

    Post MY code

    main()
    {
    int x = 2, y=2;
    char pos;
    again:
    drawmaze();
    gotoxy(x, y);
    printf("");
    pos = bioskey(0);
    if(pos == 's') { y = y + 1; }
    if(pos == 'w') { y = y - 1; }
    if(pos == 'a') { x = x - 1; }
    if(pos == 'd') { x = x + 1; }
    goto again;
    }

    drawmaze()
    {
    clrscr();
    printf("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄ¿\n");
    printf("³ ³ ³ ³\n");
    printf("³ ÄÄÄÄÄÄÄÄÂÄÄÄ¿ ÄÄÄÄÄÄÄÄÂÄÄÄ¿ ³ ÚÄÄÄÄ ÚÄÄÄ¿ ÄÄÄÄÂÄÄÄÄ ³ ÄÄÄÄ´\n");
    printf("³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³\n");
    printf("ÃÄÄÄÄÄÄÄ ³ ÀÄÄÄÄÄÄÄ¿ ³ ³ ÀÄÄÄÙ ³ ³ ÀÄÄÄ¿ ÀÄÄÄÄÄÄÄÁÄÄÄÄ ³\n");
    printf("³ ³ ³ ³ ³ ³ ³ ³ ³\n");
    printf("³ ÄÄÄÄÂÄÄÄÙ ÚÄÄÄÄ ³ ³ ³ ÚÄÄÄÄÄÄÄ´ ³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄ ³\n");
    printf("³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³\n");
    printf("ÃÄÄÄÄ ³ ÄÄÄÄÁÄÄÄ¿ ³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄ¿ ³ ÄÄÄ´\n");
    printf("³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³\n");
    printf("³ ÚÄÄÄÁÄÄÄÄÄÄÄ¿ ÀÄÄÄ´ ÃÄÄÄÄÄÄÄ´ ³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄ¿ ÀÄÄÄÂÄÄÄÄÄÄÄ´\n");
    printf("³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³\n");
    printf("³ ÀÄÄÄ¿ ³ ÀÄÄÄÄ ³ ³ ³ ³ ³ ³ ÚÄÄÄÄÄÄÄ¿ ÀÄÄÄ¿ ³ ³ ³\n");
    printf("³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³\n");
    printf("ÃÄÄÄ¿ ³ ³ ÚÄÄÄÄÄÄÄÙ ³ ³ ³ ÃÄÄÄÄÄÄÄÙ ³ ³ ÚÄÄÄÁÄÄÄÄÄÄÄ´ ³\n");
    printf("³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³\n");
    printf("³ ³ ³ ³ ³ ÚÄÄÄÄÄÄÄ´ ÀÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÙ ³ ³ ÚÄÄÄÄÄÄÄÙ ³\n");
    printf("³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³\n");
    printf("³ ÀÄÄÄÄÄÄÄÙ ³ ³ ³ ÀÄÄÄÄÄÄÄÄ ³ ÚÄÄÄÄÄÄÄÄ ³ ÀÄÄÄÄÄÄÄ¿ ³\n");
    printf("³ ³ ³ ³ ³ ³ E ³\n");
    printf("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÄÄÁÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÙ\n");
    }

    how can I let  stay in between the lines?

  5. #5
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    use code tags......
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

  6. #6
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    Do you know how to use arrays? You'll need to use a two-dimensional array which holds the map values. Then before you move the cursor, you check the array to make sure that spot isn't a wall.

  7. #7
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    First you need to store the world in an array: WorldArray.
    Then check whether there is an obstacle in the direction you're walking.
    Code:
    enum
    {
       Left,
       Right,
       Up,
       Down
    };
    
    bool IsObstacle(int X, int Y)
    {
       return (WorldArray[X][Y] != ' ');
    }
    
    void Move(int Direction)
    {
       switch(Direction)
       {
          case Left:
             if(IsObstacle(PlayerX - 1, PlayerY) == false)
             {
                PlayerX--;
             }
             break;
    
          case Right:
             if(IsObstacle(PlayerX + 1, PlayerY) == false)
             {
                PlayerX++;
             }
             break;
    
          case Up:
             if(IsObstacle(PlayerX, PlayerY - 1) == false)
             {
                PlayerY--;
             }
             break;
    
          case Down:
             if(IsObstacle(PlayerX, PlayerY + 1) == false)
             {
                PlayerY++;
             }
             break;
       }
    }
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  8. #8
    Registered User
    Join Date
    Mar 2003
    Posts
    6

    Question how?

    How will i do the world array?

  9. #9
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Maybe something like this:
    Code:
    char WordlArray[WIDTH][HEIGHT] =
    {{'X', 'X', ' ', 'X'},
     {'X', ' ', ' ', 'X'},
     {'X', ' ', 'X', 'X'},
     {'X', ' ', ' ', 'X'}};
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  10. #10
    Registered User
    Join Date
    Mar 2003
    Posts
    6

    ASCII

    can I use ascii in that world array?

  11. #11
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331

    Re: ASCII

    Originally posted by Oid21
    can I use ascii in that world array?
    Just out of my own curiosity, why would you?

  12. #12
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    Re: ASCII

    Originally posted by Oid21
    can I use ascii in that world array?
    If this is what you mean:
    Code:
    char WordlArray[WIDTH][HEIGHT] =
    {{3, 3, 0, 3},
     {3, 0, 0, 3},
     {3, 0, 3, 3},
     {3, 0, 0, 3}};
    Then yes!

    Originally posted by RoD
    Just out of my own curiosity, why would you?
    Maybe he wants to use special characters that can't be typed from the keyboard?
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21