Hey guys, i am learning Dark GDK and C++, and i thought i would just play around with making a FPS game just to see how to do it and to see if i could. When i use dbAutoCamOff() the camera seems to lock and doesnt move, and as soon as i take auto cam off out it works fine again, except it does not start where i specify using dbPositionCamera(). Here is my code.
// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple project that uses Dark GDK
// it contains the basic code for a GDK application
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
// the main entry point for the application is this function
void DarkGDK ( void )
{
// change the gaming window size to be full screen
dbMaximizeWindow();
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
// makes a camera and activates camera collision
dbAutoCamOff ();
dbPositionCamera(450, 50, -500);
dbAutomaticCameraCollision ( 0, 0.1, 1);
// where my objects are stored
SetCurrentDirectory ("media");
// used to rotate the camera in the code below
float fCameraAngleX = 0.0f;
float fCameraAngleY = 0.0f;
// loads the skybox and sets it up to display correctly
dbLoadObject ("skybox2.x", 1);
dbSetObjectLight (1, 0);
dbSetObjectTexture (1, 3, 2);
dbScaleObject (1, 5000, 5000, 5000);
dbPositionObject (1, 0, 0, 0);
// loads the world
dbLoadObject("universe.dbo", 2);
dbSetObjectLight (2, 0);
dbPositionObject(2, 0, 0, 0);
// our main loop
while ( LoopGDK ( ) )
{
// prevent the mouse pointer from being displayed
dbHideMouse();
// rotate the camera when the mouse is moved
fCameraAngleX = dbWrapValue (fCameraAngleX + dbMouseMoveY() *0.4f);
fCameraAngleY = dbWrapValue (fCameraAngleY + dbMouseMoveX() *0.4f);
dbXRotateCamera (fCameraAngleX);
dbYRotateCamera (fCameraAngleY);
// move forwards
if(dbKeyState(17))
{
dbMoveCamera (0, 4);
}
// move backwards
if(dbKeyState(31))
{
dbMoveCamera (0, -3);
}
// strafe left
if (dbKeyState(30))
{
dbMoveCameraLeft(0,3);
}
// strafe right
if (dbKeyState(32))
{
dbMoveCameraRight(0,3);
}
// update the screen
dbSync ( );
}
// return back to windows
return;
}
It is probably something simple that i cannot see because i am new to coding with dark gdk and C++. Can anybody tell me why the camera stops being able to move when i use dbAutoCamOff()?
Thanks
Chappy