Just to make it clearer, here's the code for makeLevel() function in dark dungeon. So far,I haven't changed anything else.
void makeLevel()
{
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] = "{$... ";
czLevel[1] = " ... ";
czLevel[2] = " ... ";
czLevel[3] = " ... }";
czLevel[4] = "{.................... ";
czLevel[5] = " ..........^......... ";
czLevel[6] = " ............@....... ";
czLevel[7] = " ...........r........ ";
czLevel[8] = " ....b.......@....... ";
czLevel[9] = " .................... ";
czLevel[10] = " .....*.............. ";
czLevel[11] = " .....*........ng.... ";
czLevel[12] = " ......^............. ";
czLevel[13] = " ....................}";
czLevel[14] = "{ ....... ";
czLevel[15] = " ....... ";
czLevel[16] = " ....... }";
czLevel[17] = "{.................... ";
czLevel[18] = " .................... ";
czLevel[19] = " .................... ";
czLevel[20] = " ...........b........ ";
czLevel[21] = " ...@...@.....^..^... ";
czLevel[22] = " ....................}";
czLevel[23] = "{ ..... ";
czLevel[24] = " ..... ";
czLevel[25] = " ..... }";
czLevel[26] = "{............. ";
czLevel[27] = " ............. ";
czLevel[28] = " ............. ";
czLevel[29] = " ...........^. ";
czLevel[30] = " .......r..... ";
czLevel[31] = " .^........... ";
czLevel[32] = " ............. ";
czLevel[33] = " .....*..*.... ";
czLevel[34] = " ............. }";
czLevel[35] = "{ ........... ";
czLevel[36] = " ........... ";
czLevel[37] = " ........... }";
czLevel[38] = "{.................... ";
czLevel[39] = " ...............^.... ";
czLevel[40] = " .................... ";
czLevel[41] = " .................... ";
czLevel[42] = " .....g.............. ";
czLevel[43] = " .................... ";
czLevel[44] = " .................... ";
czLevel[45] = " .........@.......@.. ";
czLevel[46] = " ...@..........r.*... ";
czLevel[47] = " .......*............ ";
czLevel[48] = " ......^.......^..... ";
czLevel[49] = " ....................}";
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 '+': // empty space
{
addFloor = 1;
} break;
case 's': // south facing door empty space
{
dbLoadObject ( "media\\door_frame1.x" , objectCount );
dbPositionObject ( objectCount , ( float ) charNum * 100 , 50 , ( float ) stringNum * 100 );
dbScaleObject ( objectCount , 180 , 160 , 130 );
dbMoveObject ( objectCount , -10 );
dbFadeObject ( objectCount , 200 );
dbSetObjectCollisionOff ( objectCount );
door[ doorCount ].type = 0; // south
door[ doorCount ].distObj = ( objectCount );
objectCount++;
dbLoadObject ( "media\\door_1a.x" , objectCount );
dbPositionObject ( objectCount , ( float ) charNum * 100 , 50 , ( float ) stringNum * 100 );
dbScaleObject ( objectCount , 100 , 110 , 100 );
dbMoveObject ( objectCount , 5 );
dbSetObjectCollisionOff ( objectCount );
door[ doorCount ].leftObj = ( objectCount );
door[ doorCount ].leftStartX = dbObjectPositionX ( objectCount );
door[ doorCount ].leftCurrentX = dbObjectPositionX ( objectCount );
objectCount++;
dbLoadObject ( "media\\door_1b.x" , objectCount );
dbPositionObject ( objectCount , ( float ) charNum * 100 , 50 , ( float ) stringNum * 100 );
dbScaleObject ( objectCount , 100 , 110 , 100 );
dbMoveObject ( objectCount , 5 );
dbSetObjectCollisionOff ( objectCount );
door[ doorCount ].rightObj = ( objectCount );
door[ doorCount ].rightStartX = dbObjectPositionX ( objectCount );
door[ doorCount ].rightCurrentX = dbObjectPositionX ( objectCount );
objectCount++;
doorCount++;
addFloor = 1;
} break;
case 'n': // north facing door empty space
{
dbLoadObject ( "media\\door_frame1.x" , objectCount );
dbPositionObject ( objectCount , ( float ) charNum * 100 , 50 , ( float ) stringNum * 100 );
dbYRotateObject ( objectCount , 180 );
dbScaleObject ( objectCount , 180 , 160 , 130 );
dbMoveObject ( objectCount , -10 );
dbFadeObject ( objectCount , 200 );
dbSetObjectCollisionOff ( objectCount );
door[ doorCount ].type = 1; // south
door[ doorCount ].distObj = ( objectCount );
objectCount++;
dbLoadObject ( "media\\door_1a.x" , objectCount );
dbPositionObject ( objectCount , ( float ) charNum * 100 , 50 , ( float ) stringNum * 100 );
dbYRotateObject ( objectCount , 180 );
dbScaleObject ( objectCount , 100 , 110 , 100 );
dbMoveObject ( objectCount , 5 );
dbSetObjectCollisionOff ( objectCount );
door[ doorCount ].leftObj = ( objectCount );
door[ doorCount ].leftStartX = dbObjectPositionX ( objectCount );
door[ doorCount ].leftCurrentX = dbObjectPositionX ( objectCount );
objectCount++;
dbLoadObject ( "media\\door_1b.x" , objectCount );
dbPositionObject ( objectCount , ( float ) charNum * 100 , 50 , ( float ) stringNum * 100 );
dbYRotateObject ( objectCount , 180 );
dbScaleObject ( objectCount , 100 , 110 , 100 );
dbMoveObject ( objectCount , 5 );
dbSetObjectCollisionOff ( objectCount );
door[ doorCount ].rightObj = ( objectCount );
door[ doorCount ].rightStartX = dbObjectPositionX ( objectCount );
door[ doorCount ].rightCurrentX = dbObjectPositionX ( objectCount );
objectCount++;
doorCount++;
addFloor = 1;
} break;
case '~': // north facing door empty space
{
dbLoadObject ( "media\\door_frame1.x" , objectCount );
dbPositionObject ( objectCount , ( float ) charNum * 100 , 50 , ( float ) stringNum * 100 );
dbYRotateObject ( objectCount , 180 );
dbScaleObject ( objectCount , 180 , 160 , 130 );
dbMoveObject ( objectCount , -10 );
dbFadeObject ( objectCount , 200 );
dbSetObjectCollisionOff ( objectCount );
door[ doorCount ].type = 1; // south
door[ doorCount ].distObj = ( objectCount );
objectCount++;
dbLoadObject ( "media\\door_1a.x" , objectCount );
dbPositionObject ( objectCount , ( float ) charNum * 100 , 50 , ( float ) stringNum * 100 );
dbYRotateObject ( objectCount , 180 );
dbScaleObject ( objectCount , 100 , 110 , 100 );
dbMoveObject ( objectCount , 5 );
dbSetObjectCollisionOff ( objectCount );
door[ doorCount ].leftObj = ( objectCount );
door[ doorCount ].leftStartX = dbObjectPositionX ( objectCount );
door[ doorCount ].leftCurrentX = dbObjectPositionX ( objectCount );
objectCount++;
dbLoadObject ( "media\\door_1b.x" , objectCount );
dbPositionObject ( objectCount , ( float ) charNum * 100 , 50 , ( float ) stringNum * 100 );
dbYRotateObject ( objectCount , 180 );
dbScaleObject ( objectCount , 100 , 110 , 100 );
dbMoveObject ( objectCount , 5 );
dbSetObjectCollisionOff ( objectCount );
door[ doorCount ].rightObj = ( objectCount );
door[ doorCount ].rightStartX = dbObjectPositionX ( objectCount );
door[ doorCount ].rightCurrentX = dbObjectPositionX ( objectCount );
objectCount++;
doorCount++;
addFloor = 1;
} break;
case '^': // empty space
{
dbLoadObject ( "media\\Energy-Box.X" , objectCount );
dbPositionObject ( objectCount , ( float ) charNum * 100 , 25 , ( float ) stringNum * 100 );
dbScaleObject ( objectCount , 400 , 400 , 400 );
dbSetObjectAmbient ( objectCount , 0 );
dbSetObjectAmbience ( objectCount , 0x00000000 );
dbSetObjectSpecular ( objectCount , 0x00111111 );
objectCount++;
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 '@': // Add Monster Baddie start plus empty space
{
dbLoadObject ("media\\Bezerker.X" , baddieCount + 100 );
//dbMakeObjectCube ( baddieCount + 100 , 50 );
dbTextureObject ( baddieCount + 100 , 2 );
dbRotateObject ( baddieCount + 100 , -90 , 0 , 0 );
dbFixObjectPivot ( baddieCount + 100 );
dbSetObjectSpeed ( baddieCount + 100 , 20000 );
//dbScaleObject ( baddieCount + 100 , 100.0f , 60.0f , 120.0f );
dbPositionObject ( baddieCount + 100 , ( float ) charNum * 100.0f , 0.0f , ( float ) stringNum * 100.0f );
//dbSetObjectCollisionOff ( baddieCount + 100 );
dbSetObjectCollisionToBoxes ( baddieCount + 100 );
//dbAutomaticObjectCollision ( baddieCount + 100 , 10 , 0 );
//dbShowObjectBounds ( baddieCount + 100 , 0 );
baddie[ baddieCount ].obj = baddieCount + 100;
baddie[ baddieCount ].life = 3;
baddie[ baddieCount ].mode = 0;
baddie[ baddieCount ].type = 0;
baddie[ baddieCount ].firing = false;
dbMakeObjectPlane ( baddieCount + 200 , 40 , 40 );
dbXRotateObject ( baddieCount + 200 , -90 );
dbTextureObject ( baddieCount + 200 , 3 );
dbSetObjectTransparency ( baddieCount + 200 , 1 );
dbPositionObject ( baddieCount + 200 , ( float ) charNum * 100.0f , 0.1f , ( float ) stringNum * 100.0f );
dbSetObjectCollisionOff ( baddieCount + 200 );
baddieCount++;
addFloor = 1;
} break;
case '*': // Add Assault Trooper Baddie start plus empty space
{
dbLoadObject ("media\\Assault Trooper.X" , baddieCount + 100 );
//dbMakeObjectCube ( baddieCount + 100 , 50 );
//dbTextureObject ( baddieCount + 100 , 2 );
dbRotateObject ( baddieCount + 100 , -90 , 0 , 0 );
dbFixObjectPivot ( baddieCount + 100 );
dbSetObjectSpeed ( baddieCount + 100 , 20000 );
dbScaleObject ( baddieCount + 100 , 90.0f , 90.0f , 90.0f );
dbPositionObject ( baddieCount + 100 , ( float ) charNum * 100.0f , 0.0f , ( float ) stringNum * 100.0f );
//dbSetObjectCollisionOff ( baddieCount + 100 );
dbSetObjectCollisionToBoxes ( baddieCount + 100 );
dbSetObjectAmbient ( baddieCount + 100, 0 );
dbSetObjectAmbience ( baddieCount + 100, 0x00000000 );
dbSetObjectSpecular ( baddieCount + 100, 0x00111111 );
//dbAutomaticObjectCollision ( baddieCount + 100 , 10 , 0 );
//dbShowObjectBounds ( baddieCount + 100 , 0 );
baddie[ baddieCount ].obj = baddieCount + 100;
baddie[ baddieCount ].life = 3;
baddie[ baddieCount ].mode = 0;
baddie[ baddieCount ].type = 1;
baddie[ baddieCount ].firing = false;
dbMakeObjectPlane ( baddieCount + 200 , 40 , 40 );
dbXRotateObject ( baddieCount + 200 , -90 );
dbTextureObject ( baddieCount + 200 , 3 );
dbSetObjectTransparency ( baddieCount + 200 , 1 );
dbPositionObject ( baddieCount + 200 , ( float ) charNum * 100.0f , 0.1f , ( float ) stringNum * 100.0f );
dbSetObjectCollisionOff ( baddieCount + 200 );
baddieCount++;
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 , 4 );
#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 , 6 );
//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 , 4 );
#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 , 6 );
//dbSetObjectCollisionOff ( objectCount );
//dbScaleObjectTexture ( objectCount , 2 , 2 );
//dbSetBumpMappingOn ( objectCount , 5 );
objectCount++;
addFloor = 0;
} break;
case 'o': // Pillars
{
dbMakeObjectCylinder ( objectCount , 100 );
dbScaleObject ( objectCount , 50 , 200 , 50 );
dbPositionObject ( objectCount , ( float ) charNum * 100 , 100 , ( float ) stringNum * 100 );
dbTextureObject ( objectCount , 5 );
dbScaleObjectTexture ( objectCount , 2 , 4 );
#ifdef SHADERS
dbSetBumpMappingOn ( objectCount , 9 );
#endif
objectCount++;
addFloor = 1;
shadow = 1;
} break;
case '#': // Doorway
{
//dbMakeObjectBox ( objectCount , 100, 100 , 100 );
dbLoadObject ( "media\\walltop3.x" , objectCount );
dbPositionObject ( objectCount , ( float ) charNum * 100 , 150 , ( float ) stringNum * 100 );
dbTextureObject ( objectCount , 6 );
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 );
if ( shadow == 1 )
{
objectCount++;
dbMakeObjectPlane ( objectCount , 100, 100 );
dbXRotateObject ( objectCount , -90 );
dbPositionObject ( objectCount , ( float ) charNum * 100 , .05f , ( float ) stringNum * 100 );
dbTextureObject ( objectCount , 7 );
dbSetObjectCollisionOff ( objectCount );
//dbFadeObject (objectCount , 200 );
}
objectCount++;
}
}
}
}