I am Trying to make a simple WWII fps and am getting problems the gun spins around (it wont stay exactly with me )
and I can fly(I need to be able to stay on the ground)
here is my code
#include "DarkGDK.h"
float g_fSpeed = 0.2f;
float g_fTurn = 0.03f;
float OldCamAngleY;
float OldCamAngleX;
float CameraAngleY;
float CameraAngleX;
float cx;
float cy;
float cz;
void GetUserInput ( void )
{
dbPositionMouse(dbScreenWidth()/2,dbScreenHeight()/2 );
dbControlCameraUsingArrowKeys ( 0, g_fSpeed, g_fTurn );
OldCamAngleY = CameraAngleY;
OldCamAngleX = CameraAngleX;
CameraAngleY = dbWrapValue ( CameraAngleY + dbMouseMoveX ( ) * 0.4f );
CameraAngleX = dbWrapValue ( CameraAngleX + dbMouseMoveY ( ) * 0.4f );
dbYRotateCamera ( dbCurveAngle ( CameraAngleY, OldCamAngleY, 24 ) );
if ( dbUpKey() || dbKeyState( 17 ) == 1 )
{
dbMoveCamera ( 0 , g_fSpeed);
}
if ( dbDownKey() || dbKeyState( 31 ) == 1 )
{
dbMoveCamera ( 0 , -g_fSpeed );
}
if ( dbLeftKey() || dbKeyState( 30 ) == 1 )
{
dbYRotateCamera ( 0 , dbCameraAngleY( 0 ) -90 );
dbMoveCamera ( 0 , g_fSpeed);
dbYRotateCamera ( 0 , dbCameraAngleY( 0 ) +90 );
}
if ( dbRightKey() || dbKeyState( 32 ) == 1 )
{
dbYRotateCamera ( 0 , dbCameraAngleY( 0 ) + 90 );
dbMoveCamera ( 0 , g_fSpeed);
dbYRotateCamera ( 0 , dbCameraAngleY( 0 ) -90 );
}
float OldCamAngleY = dbCameraAngleY ( 0 );
float OldCamAngleX = dbCameraAngleX ( 0 );
dbPositionCamera ( 0 , dbCameraPositionX ( 0 ) , dbCameraPositionY() , dbCameraPositionZ ( 0 ) );
//GUN
dbPositionObject ( 1, dbCameraPositionX ( 0 ) , dbCameraPositionY ( 0 )-0.11 , dbCameraPositionZ( 0 ) );
}
void DarkGDK ( void )
{
dbSyncRate ( 60 );
dbSyncOn ( );
dbSetCameraRange ( 0.05f, 30000 );
dbLoadBSP ( "ikzdm1.pk3", "ikzdm1.bsp" );
dbSetBSPCameraCollision ( 1, 0, 0.75, 0 );
dbLoadObject("media\\weapons\\H-MP40-Static.x", 1);
dbSetObjectLight ( 1, 0 );
dbDisableObjectZDepth ( 1 );
dbLoadSound ( "media\\shot.wav" , 1);
dbLoadObject ( "media\\sky\\skybox2.x", 200 );
dbSetObjectLight ( 200, 0 );
dbSetObjectTexture ( 200, 3, 1 );
dbPositionObject ( 200, 1000, 2000, 4000 );
dbScaleObject ( 200, 30000, 30000, 30000 );
dbFixObjectPivot(1);
dbPositionCamera ( 0.0f, 0.5f, 0.0f );
while(LoopGDK()) {
GetUserInput ();
dbRotateCamera(CameraAngleX,CameraAngleY,dbCameraAngleZ());
dbSetObjectToCameraOrientation(1);
if(dbMouseClick() ==1) {
dbPlaySound(1);
dbSleep(1);
}
dbSync ( );
}
return;
}