There have been a couple of posts lately with mazes, as well as various questions on mazes, which of course sparked my interest, and led to my latest toy.
The project comes with a secondary program, namely GenerateMaze.exe. This program creates a text file of a randomly generated maze. The chances of you generating two identical mazes, is about 1 in 5 million. So you are always sure to have a unique new maze whenever you run this program. The program is written in C, using some algorithms I got from the web.
The project _RadMazer_ generates a 3d maze with imposter boxes, based on the text file. You may use this project as a foundation for your own maze based games if you wish; which is intended purpose of the post anyway.
When the project starts, it generates the 3d maze, and you must see if you can go through the maze in 1st person camera view. You can switch to a top down view with the middle mouse button, but you can't move in this view. Middle mouse button toggles back to 1st person view if clicked again.
Andro shows you where you are located in the maze, when you use the top down view.
V7.22 - But here is the script for those who don't have 7.22, but do have a version that supports imposter RB's
With a million versions floating around, I can only support 6.50/7.03 and 7.22
The project comes with a secondary program, namely GenerateMaze.exe. This program creates a text file of a randomly generated maze. The chances of you generating two identical mazes, is about 1 in 5 million. So you are always sure to have a unique new maze whenever you run this program. The program is written in C, using some algorithms I got from the web.
The project _RadMazer_ generates a 3d maze with imposter boxes, based on the text file. You may use this project as a foundation for your own maze based games if you wish; which is intended purpose of the post anyway.
When the project starts, it generates the 3d maze, and you must see if you can go through the maze in 1st person camera view. You can switch to a top down view with the middle mouse button, but you can't move in this view. Middle mouse button toggles back to 1st person view if clicked again.
Andro shows you where you are located in the maze, when you use the top down view.
V7.22 - But here is the script for those who don't have 7.22, but do have a version that supports imposter RB's
With a million versions floating around, I can only support 6.50/7.03 and 7.22
Code: [Select]
int BLOCK = OBJ_0;
int CAM1 = OBJ_44;
int CAM3 = OBJ_22;
int ANDRO = OBJ_66;
int max = 441;
bool CHEAT = false;
//----------------------------------------------------------------------
void NewMaze()
{
int i,j,c,fh,p;
Quaternion q = Quaternion(0,0,0,0);
Vector3 location;
string s;
//hide imposters and master
iObjectLocationSet(BLOCK,Vector3(-1000,-1000,-1000));
for(i=0;i<max;i++){
iObjectImposterSet(BLOCK,i,q,Vector3(-1000,-1000,-1000));
}
//place all possible blocks into position
c=0;
for(i=0;i<21;i++){
for(j=0;j<21;j++){
location.x = (i*3) -30;
location.z = (j*3) -30;
location.y = 0;
iObjectImposterSet(BLOCK,c,q,location);
c++;
}
}
//load maze file and generate maze - remove accesable blocks
fh = iFileReadOpen(".\\maze.txt");
for(i = 0;i<21;i++){
iFileStringRead(fh,s);
for(j=0;j<21;j++){
p = s[j];
//iObjectTextSet(OBJ_22,p);
if(p == 32){
c = i*21+j;
iObjectImposterSet(BLOCK,c,q,Vector3(-1000,-1000,-1000));
}
}
}
iFileClose(fh);
}
//----------------------------------------------------------------------
void Main()
{
Vector3 location;
Quaternion orientation;
if(iInitializing()){
iObjectImpostersCreate(BLOCK,max);
NewMaze();
iObjectHide(CAM3);
iObjectShow(CAM1);
iObjectHide(ANDRO);
}
if(iDeinitializing())
{
iObjectImpostersDestroy(BLOCK);
}
if(iMouseButtonClick(2)){
if(!CHEAT){
CHEAT = true;
iObjectHide(CAM1);
iObjectShow(CAM3);
iObjectShow(ANDRO);
}else{
CHEAT = false;
iObjectHide(CAM3);
iObjectShow(CAM1);
iObjectHide(ANDRO);
}
}
iObjectLocation(CAM1,location);
iObjectOrientation(CAM1,orientation);
location.y -=3;
iObjectLocationSet(ANDRO,location);
iObjectOrientationSet(ANDRO,orientation);
}