Ive converted the DBPRO tutorial, huge dungeons to work in dark gdk, although at the moment it doesnt have collision and I changed the control system to just arrow keys, since its more oldschool. You'll need the media from the original:
http://files.thegamecreators.com/developer/dbpro/DBPro_Tutorial_6_Huge_Dungeons.zip
#include "DarkGDK.h"
const int mapSize = 512;
int map[mapSize][mapSize];
void loadMap(char* fileName, int size)
{
int tmp=0;
int tmp1=0;
tmp = dbFileExist(fileName);
dbOpenToRead(1, fileName);
for (int y=1; y<=size; y++)
{
for (int x=1; x<=size; x++)
{
tmp1=int(dbReadByte(tmp));
map[x][y]=tmp1;
}
}
}
void DarkGDK ( void )
{
dbSetDisplayMode(1024,768,32);
dbSyncOn();
dbSyncRate(60);
dbRandomize(dbTimer());
dbAutoCamOff();
dbHideMouse();
dbInk(dbRGB(255,255,255),dbRGB(0,0,0));
dbBackdropOn();
dbColorBackdrop(dbRGB(0,0,0));
int curposx = 0;
int curposz = 0;
int cx = 0;
int cz = 0;
int zzz = 0;
int maxCells = 16;
int cellSize = 200;
int keypressCount = 0;
int keypressDelay = 10;
dbFogOn();
dbFogColor(dbRGB(0,0,0));
dbFogDistance((maxCells*cellSize)-cellSize*8);
dbSetCameraRange(1,(maxCells*cellSize));
// lighting
dbSetAmbientLight(30);
dbMakeLight(1);
dbMakeLight(2);
dbSetPointLight(1,0,0,0);
dbSetSpotLight(2,45,90);
dbSetLightRange (1, maxCells*cellSize);
dbSetLightRange (2, maxCells*cellSize);
dbColorLight(2,RGB(252,216,141));
dbColorLight(1,RGB(236,182,100));
dbHideLight(0);
// textures
dbLoadImage("media/wall2.jpg",1);
dbLoadImage("media/ground.jpg",2);
dbLoadImage("media/wall.jpg",3);
loadMap("media/dungeon.map",mapSize);
// walls
for (int i=1; i<=maxCells*maxCells; i++)
{
dbMakeObjectCube(100+i,cellSize);
dbTextureObject(100+i,1);
}
// floor
for (int i=1; i<=maxCells*maxCells; i++)
{
dbMakeObjectPlain(10000+i,cellSize,cellSize);
dbRotateObject(10000+i,90,0,0);
dbTextureObject(10000+i,2);
}
// ceiling
for (int i=1; i<=maxCells*maxCells; i++)
{
dbMakeObjectPlain(20000+i,cellSize,cellSize);
dbRotateObject(20000+i,270,0,0);
dbTextureObject(20000+i,3);
}
// Search startpoint
for (int z=1; z<=mapSize; z++)
{
for (int x=1; x<mapSize; x++)
{
if (map[x][z]==79)
{
cx=x*cellSize;
cz=z*cellSize;
}
if (map[x][z]==85)
{
// downstairs
}
}
}
dbPositionCamera(cx,0,cz);
dbCLS();
while ( LoopGDK ( ) )
{
if (dbUpKey()==1 && keypressCount==0)
{
dbMoveCamera(cellSize);
keypressCount=keypressDelay;
}
if (dbDownKey()==1 && keypressCount==0)
{
dbMoveCamera(cellSize*-1);
keypressCount=keypressDelay;
}
if (dbLeftKey()==1 && keypressCount==0)
{
dbYRotateCamera(dbCameraAngleY()-90);
keypressCount=keypressDelay;
}
if (dbRightKey()==1 && keypressCount==0)
{
dbYRotateCamera(dbCameraAngleY()+90);
keypressCount=keypressDelay;
}
if (keypressCount!=0) keypressCount=keypressCount-1;
cx=int(dbCameraPositionX()/cellSize)-int(maxCells/2);
cz=int(dbCameraPositionZ()/cellSize)-int(maxCells/2);
zzz=0;
for (int zz=1; zz<=maxCells; zz++)
{
for (int xx=1; xx<=maxCells; xx++)
{
zzz=zzz+1;
curposx=cx+xx;
curposz=cz+zz;
if (curposx<=1) curposx=1;
if (curposx>=mapSize) curposx=mapSize;
if (curposz<=1) curposz=1;
if (curposz>=mapSize) curposz=mapSize;
// Wall
// if (map[curposx][curposz]==dbAsc("#") || map[curposx][curposz]==dbAsc("S")) {
if (map[curposx][curposz]==35 || map[curposx][curposz]==83) {
dbShowObject(100+zzz);
dbPositionObject(100+zzz,curposx*cellSize,0.0,curposz*cellSize);
} else {
dbHideObject(100+zzz);
}
// Floor
// if (map[curposx][curposz]==dbAsc(":") || map[curposx][curposz]==dbAsc("D") || map[curposx][curposz]==dbAsc("S") || map[curposx][curposz]==dbAsc("T")) {
if (map[curposx][curposz]==58 || map[curposx][curposz]==68 || map[curposx][curposz]==83 || map[curposx][curposz]==84) {
dbShowObject(10000+zzz);
dbPositionObject(10000+zzz,curposx*cellSize,(cellSize/2)*(-1),curposz*cellSize);
dbShowObject(20000+zzz);
dbPositionObject(20000+zzz,curposx*cellSize,(cellSize/2),curposz*cellSize);
} else {
dbHideObject(10000+zzz);
dbHideObject(20000+zzz);
}
}
}
dbPositionLight(1,dbCameraPositionX(),dbCameraPositionY(),dbCameraPositionZ());
dbPositionLight(2,dbCameraPositionX(),dbCameraPositionY(),dbCameraPositionZ());
dbColorLight(1,dbRGB(200+int(dbRnd(50)-25),120,60));
dbRotateLight(2,dbCameraAngleX(),dbCameraAngleY(),dbCameraAngleZ());
dbSync();
}
// before quitting delete our objects
// walls
for (int i=1; i<=maxCells*maxCells; i++)
{
if(dbObjectExist(100+i)) dbDeleteObject(100+i);
}
// floor
for (int i=1; i<=maxCells*maxCells; i++)
{
if(dbObjectExist(10000+i)) dbDeleteObject(10000+i);
}
// ceiling
for (int i=1; i<=maxCells*maxCells; i++)
{
if(dbObjectExist(20000+i)) dbDeleteObject(20000+i);
}
return;
}