All right, it works. Here is the code.
#include "DarkGDK.h"
//#include "QuickODE.h"
//QuickODE Physics;
char buffer[256];
float mPerSecond = 60.0;
int prevTime, curTime;
//int syncRate = 60;
int an = 0;
int ya;
void DarkGDK()
{
dbSyncOn();
dbSyncRate (60);
//Physics.Start();
//Physics.SetGravity (0, -9.8f, 0);
dbText (0, 10, "Please Wait...");
dbSync();
dbSync();
dbMakeObjectBox(1, 10, 20, 30);
for (int i = 2; i < 4000; i++)
{
dbMakeObjectSphere (i, 10);
dbPositionObject (i, dbRnd (1000), dbRnd (40), dbRnd (1000));
}
prevTime = curTime = dbTimer();
while (LoopGDK())
{
//Physics.Update();
int angle = dbObjectAngleY(1) + an;
dbSetCameraToFollow (dbObjectPositionX(1), dbObjectPositionY(1), dbObjectPositionZ(1), angle, 200, 100, 12, 0);
sprintf(buffer, "%d", dbScreenFPS());
dbText (0, 0, buffer);
curTime = dbTimer();
float timeDiff = curTime - prevTime;
prevTime = curTime;
float speed = timeDiff * mPerSecond / 1000.0;
if (dbKeyState (17))
dbMoveObject (1, speed);
if (dbKeyState (31))
dbMoveObject (1, -speed);
if (dbKeyState (30))
ya = ya - 2;
if (dbKeyState(32))
ya = ya + 2;
dbYRotateObject (1, ya);
dbSync();
}
dbText (0, 20, "Please Wait...");
dbSync();
dbSync();
//Physics.Stop();
for (int i = 1; i < 4000; i++)
dbDeleteObject (i);
return;
}
One other thing, how do I control how fast the player moves. Like, I want to speed it ( the box ) up and slow it down when the key is released.