how to get the walls from input?
-
Hello all; I'm a beginner in c. I should program a game(it's maze). So I am dealing with this problem that can't get the walls from input. because user should be able to put the walls by using an array. Apologise me because bad English writing.
-
Hello all; I'm a beginner in c. I should program a game(it's maze). So I am dealing with this problem that can't get the walls from input. because user should be able to put the walls by using an array. Apologise me because bad English writing.
For example, this code generates a random maze. Its a console application
#include <iostream.h>
#include <conio.h>
#include <time.h>
#include <stdlib.h>int main()
{
system("color 1F");
int rows,columns,r,k;
int center,c;
int random_it;
char someCharacter;
char lgt1='\xB3';
char lgt3='\xBF';
char lgt10='\xD9';
srand(time(0));//system("color 1F") cout<<"Maze generator ver 0.000000000001 beta \\n\\n"; cout<<"Input columns (x) > "; cin>>columns; cout<<"Input rows (y) > "; cin>>rows; center=38-(columns/2); cout<<'\\n'; for (r=0;r<rows;r++) { for (c=0;c<center;c++) cout<<" ";//cout<<"|"; for(k=0;k<columns;k++) { random\_it=rand() % 20; if (random\_it==0) someCharacter=random\_it+lgt1; if (random\_it==1) someCharacter=random\_it+lgt1; if (random\_it==2) someCharacter=random\_it+lgt3-2; if (random\_it==3) someCharacter=random\_it+lgt3-2; if (random\_it==4) someCharacter=random\_it+lgt3-2; if (random\_it==5) someCharacter=random\_it+lgt3-2; if (random\_it==6) someCharacter=random\_it+lgt3-2; if (random\_it==7) someCharacter=random\_it+lgt3-2; if (random\_it==8) someCharacter=random\_it+lgt3-2; if (random\_it==9) someCharacter=random\_it+lgt10-9; if (random\_it==10) someCharacter=random\_it+lgt10-9; if (random\_it>10) someCharacter='\\x20'; cout<<(char)someCharacter; } //cout<<"|\\n"; cout<<"\\n"; } cout<<"\\n"; return 0;
}
...
-
Hello all; I'm a beginner in c. I should program a game(it's maze). So I am dealing with this problem that can't get the walls from input. because user should be able to put the walls by using an array. Apologise me because bad English writing.
This question reminds me of one of my articles, Fast Generation of Single-Solution Mazes[^]. Of course, one big difference is that in the article I deal with automatically generated mazes. I think you are wanting to let the user of the program input the maze. Maybe the article can still give you some ideas about certain things, e.g. data structures. Personally, if I needed to allow the user to enter a "wall" character from the console, I would use the | character, perhaps in conjunction with the _ character. Or, you could use menus of some sort. Even in a text-based application, it's possible to have a menu, e.g. 1....File 2....Print 3....About