hey guys I have a game I am working on and being the noob that I am I need some help. I don't know why but when I start the game the camera is stuck to the ground and I can't move unless I look way up. But then I am floating. Anyways here is the code any help is appreciated
//title Diablo
#include "DarkGDK.h"
float fCameraAngleX = 0.0f; //variable for the cameras x angle
float fCameraAngleY = 0.0f; //variable for the cameras y angle
float grav = 1; //our variable for gravity
void phisics ()
{
dbPositionCamera (dbCameraPositionX(0),dbCameraPositionY(0)-grav,dbCameraPositionZ(0));
}
void control ()
{
// move the camera using the wsad keys
if ( dbUpKey() || dbKeyState( 17 ) == 1 )
{
dbMoveCamera ( 0 , 0.5);
//gunWaggle += 0.5f;
//gunWaggle2 += 0.25f;
}
if ( dbDownKey() || dbKeyState( 31 ) == 1 )
{
dbMoveCamera ( 0 , -0.5 );
//gunWaggle += 0.5f;
//gunWaggle2 += 0.25f;
}
if ( dbLeftKey() || dbKeyState( 30 ) == 1 )
{
dbYRotateCamera ( 0 , dbCameraAngleY( 0 ) -90 );
dbMoveCamera ( 0 , 0.5);
dbYRotateCamera ( 0 , dbCameraAngleY( 0 ) +90 );
}
if ( dbRightKey() || dbKeyState( 32 ) == 1 )
{
dbYRotateCamera ( 0 , dbCameraAngleY( 0 ) + 90 );
dbMoveCamera ( 0 , 0.5);
dbYRotateCamera ( 0 , dbCameraAngleY( 0 ) -90 );
}
// create a rotation axis based on mouse movement
fCameraAngleX = dbWrapValue ( fCameraAngleX + dbMouseMoveY ( ) * 0.4f );
fCameraAngleY = dbWrapValue ( fCameraAngleY + dbMouseMoveX ( ) * 0.4f );
// rotate camera
dbXRotateCamera (0, fCameraAngleX );
dbYRotateCamera (0, fCameraAngleY );
}
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
//dbSetWindowOff (); //fullscreen
dbHideMouse ();
dbPositionMouse (0, 0);
dbAutoCamOff ();
// switch to the media directory, load our world
// and turn lighting off
SetCurrentDirectory ( "media" );
dbLoadObject ( "testmap.dbo", 1 );
dbSetObjectLight ( 1, 0 );
dbSetObjectCollisionToPolygons (1);
dbAutomaticCameraCollision (0,3,10);
while ( LoopGDK ( ) )
{
phisics();
control();
// update the screen
dbSync ( );
}
}
thx
Happy snoodle day