Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Fps Movement

Author
Message
Eggie
14
Years of Service
User Offline
Joined: 10th Oct 2010
Location:
Posted: 18th Oct 2010 00:08
I'm making an fps but the movement isn't working right. The camera doesn't move to where I point. Only on a straight line.
My code is:
#include "DarkGDK.h"

void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );

dbMaximizeWindow ( );
dbHideMouse ( );

dbLoadObject ( "Test Level.x", 1 );
dbSetObjectLight ( 1, 10000 );
dbRotateObject ( 1, 90, 0, 0 );
dbScaleObject ( 1, 10000, 10000, 10000 );

dbLoadObject ( "skybox2.x", 2 );
dbSetObjectLight ( 2, 0 );
dbSetObjectTexture ( 2, 3, 2 );
dbScaleObject ( 2, 5000, 5000, 5000 );

dbLoadObject ( "Atomiser.x", 3 );
dbRotateObject ( 3, -90, 0, 0 );
dbPositionObject ( 3, 10, -15, 20 );
dbLockObjectOn ( 3 );;
dbLoadImage ( "atomiser.bmp", 4 );


dbPositionCamera ( 434, 120, -500 );
float fCameraAngleX = 0.0f;
float fCameraAngleY = 0.0f;
float fCameraAngleZ = 0.0f;

while ( LoopGDK ( ) )
{
if ( dbKeyState(17) == 1 )
{
dbRotateCamera ( 0 , 0, -fCameraAngleZ );
dbMoveCamera ( 5 );
dbRotateCamera ( 0, 0, fCameraAngleZ );
}

if ( dbKeyState(31) == 1 )
{
dbRotateCamera ( 0, 0, -fCameraAngleZ );
dbMoveCamera ( 0, -5 );
dbRotateCamera ( 0, 0, fCameraAngleZ );
}

fCameraAngleX = dbWrapValue ( fCameraAngleX + dbMouseMoveY ( ) * 0.4f );
fCameraAngleY = dbWrapValue ( fCameraAngleY + dbMouseMoveX ( ) * 0.4f );

dbXRotateCamera ( fCameraAngleX );
dbYRotateCamera ( fCameraAngleY );

dbSync ( );
}

return;
}

Any help would be appreciated and if you know any tutorials on creating an fps, that would be very helpful.
Pilz X Schizo
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Massachusetts, USA
Posted: 18th Oct 2010 02:29
First thing I noticed was the Z rotation when you move, almost looks like you want it to strafe but it wasnt working right. I ran the code really quick and thats exactly what was going on. I just took out the rotation commands in the movement keys and it seemed to work great.


if ( dbKeyState(17) == 1 )
{
//////dbRotateCamera ( 0 , 0, -fCameraAngleZ );////
dbMoveCamera ( 5 );
/////dbRotateCamera ( 0, 0, fCameraAngleZ );////
}

if ( dbKeyState(31) == 1 )
{
//////dbRotateCamera ( 0, 0, -fCameraAngleZ );////
dbMoveCamera ( 0, -5 );
//////dbRotateCamera ( 0, 0, fCameraAngleZ );/////
}

Eggie
14
Years of Service
User Offline
Joined: 10th Oct 2010
Location:
Posted: 19th Oct 2010 06:03
Thanks, but when you point down you move downwards and the same with going up. I wanted to be able to move straight kind of like walking on ground, but still be able to look around. My first code kind of does what I want, but you can't move left or right.
Any help would be very appreciated.
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 19th Oct 2010 16:57
Don't use camera movement. Make an object (or just use some variables) and attach the camera to it. Or you can move the camera with dbPositionCamera(x,y,z); and only change the x,z in reference to the camera look angle.

The fastest code is the code never written.
Pilz X Schizo
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Massachusetts, USA
Posted: 19th Oct 2010 19:42
In that case you can just re-position to your Y value after you move. After moving just do something like dbPositionCamera(dbCameraPositionX(), YValue, dbCameraPositionZ()); to correct the height. This will become a bit more complicated if your level is going to have variable height to it, then you will need to check the maps height at that spot and assign that as your YValue.

Login to post a reply

Server time is: 2024-11-19 16:40:18
Your offset time is: 2024-11-19 16:40:18