I am Trying to make a 3D maze Program I am trying to use the same method the Dark GDK used for the First Person Shooter example. Now I don't want enemys or pillers or opening doors Just Simple objects made for walls and floors for now I have them textured as bricks but if you run this it doesn't creat anything. What is wrong and How do I fix it? Please This is a helping forum So I seek help Please.
#include "DarkGDK.h"
int CurrentVis = 0;
int visCount = 0;
int currentVis =0;
typedef struct tVis
{
int start;
int end;
int startObj;
int endObj;
} tVis;
#define MAXVIS 8 // max vis areas
void showVis ();
void updateVis ();
void setupVis ();
tVis vis[MAXVIS];
void updateVis()
{
int colZ = (int) ( ( dbCameraPositionZ ( 0 ) - 50 ) / 100.0f ) + 1;
int oldVis = currentVis;
int iLoop;
int visLoop;
int baddieLoop;
int baddieVis;
for ( iLoop = 0 ; iLoop < visCount ; iLoop++ )
{
if ( colZ >= vis[iLoop].start && colZ <= vis[iLoop].end )
{
currentVis = iLoop;
}
}
// Are we in a different vis area?
if ( currentVis != oldVis )
{
// First lets move the new blocks down (if needed)
for ( iLoop = currentVis -1 ; iLoop < currentVis + 2 ; iLoop++ )
{
// does the area need moving down?
if (iLoop > -1 && iLoop < visCount )
{
if ( dbObjectPositionY ( vis[iLoop].startObj ) > 49000 )
{
for ( visLoop = vis[iLoop].startObj ; visLoop < vis[iLoop].endObj + 1 ; visLoop++ )
{
dbMoveObjectDown ( visLoop , 50000 );
//dbExcludeOff ( visLoop );
}
}
}
}
// Now lets move the other blocks up (if needed)
for ( iLoop = 0 ; iLoop < visCount ; iLoop++ )
{
if ( iLoop < currentVis -1 || iLoop > currentVis +1 ) // dont move the current vis up
{
// does the area need moving up?
if ( dbObjectPositionY ( vis[iLoop].startObj ) < 49000 )
{
for ( visLoop = vis[iLoop].startObj ; visLoop < vis[iLoop].endObj + 1 ; visLoop++ )
{
dbMoveObjectUp ( visLoop , 50000 );
//dbExcludeOn ( visLoop );
}
}
}
}
}
}
void makeLevel ();
// the main entry point for the application is this function
void DarkGDK ( void )
{
dbLoadImage("texturebrick.jpg",1);
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
// our main loop
while ( LoopGDK ( ) )
{
updateVis ();
// update the screen
dbSync ( );
}
// return back to windows
return;
}
void makeLevel()
{
char* czLevel [55];
int objectCount = 300;
int charNum = 0;
int stringNum = 0;
int addFloor = 0;
int lightNum = 1; // can have 6 lights max in the level R, G or B
int shadow = 0;
// Define the level
czLevel[0] = "{121 ";
czLevel[1] = " 1$1 ";
czLevel[2] = " 1.1 ";
czLevel[3] = " 1.1 }";
czLevel[4] = "{1.222222222222222221 ";
czLevel[5] = " 1~........^........1 ";
czLevel[6] = " 1.o...o...o.@...2221 ";
czLevel[7] = " 1..........r...22221 ";
czLevel[8] = " 1.o.b...x.o.@......1 ";
czLevel[9] = " 1.............s....1 ";
czLevel[10] = " 1.o..*o.....22#22221 ";
czLevel[11] = " 1....*.....22.ng...1 ";
czLevel[12] = " 1.....^...22..s....1 ";
czLevel[13] = " 12222222222222#22221}";
czLevel[14] = "{ 122#221 ";
czLevel[15] = " 1#####1 ";
czLevel[16] = " 1#222#1 }";
czLevel[17] = "{122222222222#222#221 ";
czLevel[18] = " 1...........n...n..1 ";
czLevel[19] = " 1..o.....x.o.......1 ";
czLevel[20] = " 1..........b.......1 ";
czLevel[21] = " 1..@s..@.....^..^..1 ";
czLevel[22] = " 1222#222222222222221}";
czLevel[23] = "{ 1#221 ";
czLevel[24] = " 1###1 ";
czLevel[25] = " 122#1 }";
czLevel[26] = "{122222#222221 ";
czLevel[27] = " 1.....n.....1 ";
czLevel[28] = " 1...........1 ";
czLevel[29] = " 1..........^1 ";
czLevel[30] = " 1.....xr....1 ";
czLevel[31] = " 1^..........1 ";
czLevel[32] = " 1...........1 ";
czLevel[33] = " 1..s.*s.*s..1 ";
czLevel[34] = " 122#22#22#221 }";
czLevel[35] = "{ 1#22#22#221 ";
czLevel[36] = " 1#########1 ";
czLevel[37] = " 122222222#1 }";
czLevel[38] = "{12222222222#22222221 ";
czLevel[39] = " 1..........n...^...1 ";
czLevel[40] = " 1..................1 ";
czLevel[41] = " 1.o.......o......o.1 ";
czLevel[42] = " 1....g.............1 ";
czLevel[43] = " 1........x.........1 ";
czLevel[44] = " 1.o..............o.1 ";
czLevel[45] = " 1........@.......@.1 ";
czLevel[46] = " 1..@..........r.*..1 ";
czLevel[47] = " 1.o....*..o......o.1 ";
czLevel[48] = " 1.....^.......^....1 ";
czLevel[49] = " 12222222222222222221}";
for ( stringNum = 0 ; stringNum < 50 ; stringNum++ )
{
for ( charNum = 0 ; charNum < 22 ; charNum++ )
{
shadow = 0;
switch ( czLevel[ stringNum ][ charNum ] )
{
case '{':
{
vis[visCount].start = stringNum;
vis[visCount].startObj = objectCount;
} break;
case '}':
{
vis[visCount].end = stringNum;
vis[visCount].endObj = objectCount - 1;
visCount++;
} break;
case '.': // empty space
{
addFloor = 1;
} break;
case '$': // Player start plus empty space
{
dbPositionCamera ( 0 , ( float ) charNum * 100.0f , 40.0f , ( float ) stringNum * 100.0f );
addFloor = 1;
} break;
case 'r': // RED light plus empty space
{
dbMakeLight ( lightNum );
dbSetPointLight ( lightNum , ( float ) charNum * 100 , 100 , ( float ) stringNum * 100 );
dbColorLight ( lightNum , 0x00AA8888 );
lightNum++;
addFloor = 1;
} break;
case 'g': // GREEN light plus empty space
{
dbMakeLight ( lightNum );
dbSetPointLight ( lightNum , ( float ) charNum * 100 , 100 , ( float ) stringNum * 100 );
dbColorLight ( lightNum , 0x0088AA88 );
lightNum++;
addFloor = 1;
} break;
case 'b': // BLUE light plus empty space
{
dbMakeLight ( lightNum );
dbSetPointLight ( lightNum , ( float ) charNum * 100 , 100 , ( float ) stringNum * 100 );
dbColorLight ( lightNum , 0x008888AA );
lightNum++;
addFloor = 1;
} break;
case '1': // Wall block
{
dbMakeObjectBox ( objectCount , 100, 100 , 100 );
dbPositionObject ( objectCount , ( float ) charNum * 100 , 50 , ( float ) stringNum * 100 );
dbTextureObject ( objectCount , 1 );
#ifdef SHADERS
dbSetBumpMappingOn ( objectCount , 8 );
#endif
dbSetObjectCollisionOn ( objectCount );
dbSetObjectCollisionToBoxes ( objectCount);
//dbShowObjectBounds ( objectCount , 0 );
//dbFadeObject ( objectCount , 10 );
//dbScaleObjectTexture ( objectCount , 1 , 2 );
//dbSetBumpMappingOn ( objectCount , 5 );
//dbHideObject ( objectCount );
//dbGhostObjectOn ( objectCount , 0 );
objectCount++;
//dbMakeObjectBox ( objectCount , 100, 100 , 100 );
dbLoadObject ( "media\\walltop.x" , objectCount );
dbPositionObject ( objectCount , ( float ) charNum * 100 , 150 , ( float ) stringNum * 100 );
dbTextureObject ( objectCount , 1 );
//dbSetObjectCollisionOff ( objectCount );
//dbScaleObjectTexture ( objectCount , 2 , 2 );
//dbSetBumpMappingOn ( objectCount , 5 );
objectCount++;
addFloor = 0;
} break;
case '2': // Wall block
{
dbMakeObjectBox ( objectCount , 100, 100 , 100 );
dbPositionObject ( objectCount , ( float ) charNum * 100 , 50 , ( float ) stringNum * 100 );
dbTextureObject ( objectCount , 1 );
#ifdef SHADERS
dbSetBumpMappingOn ( objectCount , 8 );
#endif
dbSetObjectCollisionOn ( objectCount );
dbSetObjectCollisionToBoxes ( objectCount);
//dbShowObjectBounds ( objectCount , 0 );
//dbFadeObject ( objectCount , 10 );
//dbScaleObjectTexture ( objectCount , 1 , 2 );
//dbSetBumpMappingOn ( objectCount , 5 );
//dbHideObject ( objectCount );
//dbGhostObjectOn ( objectCount , 0 );
objectCount++;
//dbMakeObjectBox ( objectCount , 100, 100 , 100 );
dbLoadObject ( "media\\walltop2.x" , objectCount );
dbPositionObject ( objectCount , ( float ) charNum * 100 , 150 , ( float ) stringNum * 100 );
dbTextureObject ( objectCount , 1 );
//dbSetObjectCollisionOff ( objectCount );
//dbScaleObjectTexture ( objectCount , 2 , 2 );
//dbSetBumpMappingOn ( objectCount , 5 );
objectCount++;
addFloor = 0;
} break;
case '#': // Doorway
{
//dbMakeObjectBox ( objectCount , 100, 100 , 100 );
dbLoadObject ( "media\\walltop3.x" , objectCount );
dbPositionObject ( objectCount , ( float ) charNum * 100 , 150 , ( float ) stringNum * 100 );
dbTextureObject ( objectCount , 1 );
dbSetObjectCollisionOff ( objectCount );
//dbScaleObjectTexture ( objectCount , 2 , 2 );
//dbSetBumpMappingOn ( objectCount , 5 );
objectCount++;
addFloor = 1;
} break;
case 'x': // Centre Point
{
addFloor = 1;
} break;
}
if ( addFloor == 1 ) // if yes that add a floor and ceiling
{
// Add the ceiling
dbMakeObjectPlane ( objectCount , 100, 100 );
dbXRotateObject ( objectCount , 90 );
dbPositionObject ( objectCount , ( float ) charNum * 100 , 200 , ( float ) stringNum * 100 );
dbTextureObject ( objectCount , 1 );
dbSetObjectCollisionOff ( objectCount );
objectCount++;
// Now the floor
dbMakeObjectPlane ( objectCount , 100, 100 );
dbXRotateObject ( objectCount , -90 );
dbPositionObject ( objectCount , ( float ) charNum * 100 , 0 , ( float ) stringNum * 100 );
dbTextureObject ( objectCount , 1 );
dbScaleObjectTexture ( objectCount , 2 , 2 );
dbSetObjectCollisionOff ( objectCount );
}
objectCount++;
}
}
}
The quality of what a man gives without seeking anything in return shows his integrity.