I was tooling about with extremely simple vehicle control, using the cop car model from DarkMATTER, and I've come across a problem. For some reason, the moment I enter the main program loop, it freezes. I tried commenting everything inside, and it seems that the loop itself is the problem. Other than a lack of proper organization, I don't think there's anything wrong with my code:
#define car 1
#define topSpeed 50
int accelCar=0;
int reverseCruiser=20;
int reverseTimer=0;
#include "DarkGDK.h"
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
dbRandomize ( dbTimer ( ) );
dbSync();
//Debug Stuff, pauses to display the current directories files, to ensure the path to the model with be right.
dbDir();
dbPrint("Any key...");dbSync();dbSuspendForKey();
dbSetWindowTitle("Cop Attack");
dbLoadObject("Media/H-Police Car-Move.x",car);
dbTurnObjectRight(car,90);
while(LoopGDK()) {
if ((dbUpKey())&&(accelCar<topSpeed)){
accelCar++;
}
if (dbDownKey()){
dbMoveObject(car,.1);
if (reverseCruiser>5){
dbSetObjectFrame(car,reverseCruiser);
reverseCruiser--;
}
if (reverseCruiser==5){reverseCruiser=20;}
}
if ((!dbUpKey())&&(!dbDownKey())&&(dbObjectPlaying(car))){dbStopObject(car);}
if ((dbLeftKey())&&(dbUpKey())){dbTurnObjectLeft(car,1.5);}
if ((dbRightKey())&&(dbUpKey())){dbTurnObjectRight(car,1.5);}
if ((dbRightKey())&&(dbDownKey())){dbTurnObjectLeft(car,1);}
if ((dbLeftKey())&&(dbDownKey())){dbTurnObjectRight(car,1);}
dbMoveObject(car,-.05*(accelCar/10));
if ((!dbObjectPlaying(car))&&(accelCar>0)){
dbPlayObject(car,5,20);
}
if ((accelCar>10)&&(dbSpaceKey())){accelCar--;accelCar--;}
if ((accelCar>0)&&(dbSpaceKey())&&(!dbUpKey())&&(accelCar<20)){accelCar--;accelCar--;}
if ((accelCar>0)&&(!dbUpKey())){accelCar--;}
}
return;
}
A quick response would be most appreciated!
EDIT: It may be of some relevance that I'm using Windows Vista, but I've been using DarkGDK all day without incident before now. (Previously I used my laptop, which has WinXP. I installed the GDK on this computer this morning.) My other projects/solutions do work, so could it be corrupted in some way? I'm not very familiar with VC++. (I hated it before now, actually. I was hard-core Dev-C++.)
EDIT x2: Issue resolved, and man do I feel stupid. Take a quick look at the code, and you should see what's missing!
My site, for various stuff that I make.