Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

maze problem

djgaloredjgalore Posts: 56Member
hi there,

i m trying to design my own version of pac man(multiplayer game) whereby i have 2 people chasing each other around a maze. my problem is that when i get to a wall i m able to penetrate through. how do i stop this from occuring. i also need to draw a maze like this: how
do i do this? or any other maze you can think of.




****************************
* *
* * *********
********** * *
* ************ *
* *
****************************
*

Comments

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    [blue]You need to represent a maze as a 2D array, where each cell is adressed by a pair of (row,column) coordinates. Each cell can be occupied by:

    1. pacman (you control it with keyboard)
    2. chaser(s) - controlled by AI of your code
    3. wall
    4. empty space (the cell into which you can move if possible)

    First - you generate a maze walls, by simple method:

    1. Create the circles for corridors separated by walls:
    [code]
    *************************
    * *
    * ********************* *
    * * * *
    * * ***************** * *
    * * * * * *
    * * * ************* * * *
    * * * * * * * *
    * * * ************* * * *
    * * * * * *
    * * ***************** * *
    * * * *
    * ********************* *
    * *
    *************************
    [/code]
    To do that fill your whole 2D array with walls and then carve the pathways by randomly selecting a wall cell and eliminating it with a space, so you get something like this:
    [code]
    *************************
    * *
    * ** ******** ***** *** *
    * * * *
    * * ** *** ******* ** *
    * * * * * *
    * * *** *** ***** * *
    * * * * * * *
    * * * ****** **** * * *
    * * * * *
    * * ***** *** *** * *
    * * * *
    * ** ***** ****** ***** *
    * *
    *************************
    [/code]Do not remove the outer walls, or you will be able to run outside of the perimeter and that is where universe ends, so no one knows what will happen! :-)

    Jokes aside - PACMAN is not an easy game to write. Without the good AI - there is no fun at all.

    Put some cool things in the empty pathways, so you can pick them up and do some damage to the chasers. The chaser should move into the cell which gives the lower distance to your character (cell with pacman symbol). When being on a straight line with pacman (line of sight) chaser can add some little speed - very small amount, so escape is possible by turning into some nearby pathway.

    You may want to choose graphics mode for this, because text will not give as much flexibility in design.

    So, does it help?[/blue]
Sign In or Register to comment.