can we make the maze game using header files of conio.h and iostream.h

Recommended Answers

All 13 Replies

plz give me some hints to make a maze game using header files of conio.h and iostream.h i m just able to draw the game plz...tel me how can i do it i m beginner in c++" i tried my best

plz give me some hints to make a maze game using header files of conio.h and iostream.h i m just able to draw the game plz...tel me how can i do it i m beginner in c++" i tried my best

Are you using Turbo C/C++ or Borland C++? Because gotoxy() function is only available in those compiler. To make this kind of game, I would firstly make 2d of array for storing the map data.

[U]0 1 2 3 4 5 6 7 8 9 A B[/U]
[B]0[/B] : 1 0 1 0 0 0 0 0 0 0 0 0
[B]1[/B] : 1 0 1 1 1 1 1 1 1 1 1 1
[B]2[/B] : 1 0 0 0 0 0 0 0 0 0 0 0
[B]3[/B] : 1 1 1 0 1 1 1 1 1 0 1 0
[B]4[/B] : 0 0 0 0 0 0 0 0 1 1 1 0
[B]5[/B] : 1 1 1 1 1 1 1 0 1 1 1 1
[B]6[/B] : 0 0 0 0 0 0 0 0 0 0 0 0
[B]7[/B] : 1 1 1 1 1 1 1 1 1 1 1 1

The 2D array would be looking like this. The 0's represent the open space, and 1's represent the block. Using getch() to recieve the move that user has made. If the next move is blocked, then stay still and wait for another move.

are u talking about RAT IN A MAZE problem...how will the user input the next move...cordinates at the console or click with the mouse..what's the objective actually..

are u talking about RAT IN A MAZE problem...how will the user input the next move...cordinates at the console or click with the mouse..what's the objective actually..

In Turbo C++, there are clrscr(), getch(), and gotoxy() functions. With these functions, it enable us to write a mini-game with console. Using clrscr() to clear the whole screen, getch() to get input, and gotoxy() to change the coordinate.

Hi invisal,
As rajatC pointed out the OP must mention the specifications and the rules before we can help him more. He's being too much general.

Are you using Turbo C/C++ or Borland C++? Because gotoxy() function is only available in those compiler. To make this kind of game, I would firstly make 2d of array for storing the map data.

i m using borland c and i hav just draw the game usng 2d arry[code=language]i m using borland c and i hav just draw the game usng 2d arry

You're still not giving the details. Hi Ali Sher, you need to give us the rules and other specifications to help us in helping you. If you're not interested, so am I.

You're still not giving the details. Hi Ali Sher, you need to give us the rules and other specifications to help us in helping you. If you're not interested, so am I.

we should take any special character like # for path finder .User can move this character by the help of arrow keys e.g. up, down, left and right.
Use ASCII characters for arrow keys’ handling.
After exit the character successfully your program should display a greeting message of success.

Okay. Did you try doinf things suggested by invisal? If so, where are you going off-track?

One more point. Is the maze created at run time?

can u give me the code for maze game in C++ and one more thing we are using CodeBlock software, so plz can u help me out with this.

hi,
i want maze game code in C++ and we r using CodeBlock software in college.if u want i can give u the details of assignment.

#include<conio.h>
#include<stdio.h>
#define SIZE 15
#include<stdlib.h>
void main()
{
int maze,mark,stack[3];
static int
move[8][2]={-1,0,-1,1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};

int i,j,m,n,top,mov,g,h;
clrscr();
printf("enter size");
scanf("%d%d",&m,&n);
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
scanf("%d",&maze[j]);
}
}
for(i=0;i<=n+1;i++)
maze[0]=1;
for(i=0;i<=n+1;i++)
maze[m+1]=1;
for(i=0;i<=m+1;i++)
maze[0]=1;
for(i=0;i<=m+1;i++)
maze[n+1]=1;
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
mark[j]=0;
}
}
mark[1][1]=1;
stack[0][0]=1;
stack[0][1]=1;
stack[0][2]=2;
top=1;
while(top!=0)
{
i=stack[0][0];
j=stack[0][1];
mov=stack[0][2];
top=top-1;
while(mov<=7)
{
g=i+move[mov][0];
h=j+move[mov][1];

if(mark[g][h]==0&&maze[g][h]==0)
{
mark[g][h]=1;
top++;
stack[top][0]=i;
stack[top][1]=j;
mov=-1;
i=g;j=h;
}
mov=mov+1;
if(g==m&&h==n)
{
printf("
path made by the rat is");
for(i=1;i<=top;i++)
printf("
%d %d",stack[0],stack[1]);
printf("
%d %d",m,n);
getch();
exit(0);
}
}
}
}

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.