Here is the code:
dbSyncOn();
dbSyncRate(60);
dbRandomize(dbTimer());
dbLoadObject("Zombie.x", zombieID);
dbPositionObject(zombieID, 280, 0, 900);
dbRotateObject(zombieID, -90, -180, 0);
dbScaleObject(zombieID, 10.0f, 10.0f, 10.0f);
dbSetObjectFrame(zombieID, walkStart);
// Clone a bunch of zombies
for (int i = 0; i < MAX_ZOMBIES; ++i)
{
dbCloneObject(i + 5, zombieID);
dbPositionObject(i + 5, 280 + rand()%100, 0, 900+rand()%100);
dbRotateObject(i + 5, -90, -180, 0);
dbScaleObject(i + 5, 10.0f, 10.0f, 10.0f);
dbSetObjectFrame(i + 5, walkStart);
} // for i
// Position our camera back so we can view the objects
dbPositionCamera(265, 0, 847);
dbRotateCamera(0, 0, 0);
dbSetTextFont("Arial");
dbSetTextSize(14);
int frameNum = walkStart;
int deltaTime = 0, lastTime = dbTimer();
int curTime = 0, elapsedTime = 0, frameCount = 0;
char fpsBuf[32];
strcpy(fpsBuf, "FPS = 0");
while (LoopGDK())
{
dbSetObjectFrame(zombieID, frameNum);
frameNum += 80;
if (frameNum > walkEnd) frameNum = walkStart;
dbMoveObjectDown(zombieID, 0.04f);
// display some text on screen
dbText(0, 0, "Test Game");
// move the camera forwards
if (dbUpKey())
dbMoveCamera(3);
// move the camera backwards
if (dbDownKey())
dbMoveCamera(-3);
if (dbLeftKey())
dbTurnCameraLeft(3);
if (dbRightKey())
dbTurnCameraRight(3);
float camX = dbCameraPositionX();
float camZ = dbCameraPositionZ();
char buf[80];
sprintf(buf, "camX = %f, camZ = %f", camX, camZ);
dbText(0, 32, buf);
dbSync();
// Calculate the frame rate
++frameCount;
deltaTime = dbTimer() - lastTime;
elapsedTime += deltaTime;
lastTime = dbTimer();
if (elapsedTime >= 1000)
{
sprintf(fpsBuf, "FPS = %dn", frameCount);
frameCount = 0;
elapsedTime = 0;
}
dbText(0, 64, fpsBuf);