This topic is now archived and is closed to further replies.


making a maze game

Recommended Posts

I am trying to make a maze game on a console application. I''ve created a text file containing a maze I drew using ASCII text. How do I display this maze in the console application and make it so the user can move through the maze? I would most appreciate some syntax with explanations because I am just a beginner. I am especially wondering about wall detection (how to set it so user cannot move through walls). Any help would be great, thanks so much applekid

Share this post

Link to post
Share on other sites
Ok, I made DOS-MAN for my AP C++, so I can help you with those problems.

The first and easiest way is the wall detection.

You make an array of your maze''s width*height like this (console)
int Maze[80][25];

and for wall, you use number 1, for floor, you use number 0. And then when you move, you check your next step (i.e. you stepped left) and see if there''s a wall there, if not, then move there, like this:

if(PLAYER_LEFT) //however you code your movement

if(Maze[x-1][y] != 1) //x and y is player position

x--; //moves left

} //no need for else because there''s nothing to do


Now for the ASCII text display, I think there''s a file called conio.h that works with Borland C++ (the one I used at school) but I don''t know how to do it with Microsoft VC++ (yet).

With conio.h you could do this:
for(int x = 0; x < 80; x++) //the horizontal row of the maze
for(int y = 0; y < 25; y++) //the vertical row of the maze
gotoxy(x,y); // x and y is the array position for when you do a loop
if(Maze[x][y] == 1) //it is a wall
cout << ''+'';

But if you have MSVC++ then you need to do a little research on how to do this gotoxy feature.

If you have Borland, you can also do this someChar = kbhit() with conio.h, and it gets the key that you press (if you use a for left, it gets a and you deal with it). if MSVC++, then you have to do research also.

I guess that''s everything that you need to know.

If you need help, send me email at, I''ve been a beginner so don''t worry. Oh also, for the array of your map, you load in your file into that.

You know your game is in trouble when your AI says, in a calm, soothing voice, "I''m afraid I can''t let you do that, Dave"

Share this post

Link to post
Share on other sites