I can\'t seem to find why my logic isn\'t working, I\'m sure it\'s something really simple that I\'m just overlooking. But I have programmed it so that when the user pressed W, A, S or D, it should move the camera accordingly, but it doesn\'t. Here\'s the relevant code:
Here is where it\'s defined
void ciCamera::Update( )
{// For updating the position/rotation of the camera and positioning the gun
if(dbKeyState(KEY_W))
pz += 0.5;
if(dbKeyState(KEY_A))
px -= 0.5;
if(dbKeyState(KEY_S))
pz -= 0.5;
if(dbKeyState(KEY_D))
px += 0.5;
camerax = dbWrapValue( camerax + dbMouseMoveY() * 0.04f );
cameray = dbWrapValue( cameray + dbMouseMoveX() * 0.04f );
dbXRotateCamera( camerax );
dbYRotateCamera( cameray );
float oldpx = px;
float oldpy = py;
float oldpz = pz;
if( oldpx != px ||
oldpy != py ||
oldpz != pz ) //If the position has changed
dbPositionCamera( px, py, pz );
}
here is where it\'s called:
ciCamera cam( dbCameraPositionX(),
dbCameraPositionY(),
dbCameraPositionZ(),
0,0,0, \"media/H-Shotgun-Static.x\" );
// our main loop
while( LoopGDK( ) )
{
cam.Update( );
// update the screen
dbSync ( );
}
Any help would be greatly appreciated
#ifdef __NEWBIE__
MakeAnAwesomeGame(lots of badies, lots of guns, lots of stuff to do, BIG level)
#endif