Ok, well, here it goes. I have been having alot of problems getting used to this DarkGDK thing, and I have finally been able to make a 3d person perspective on GDK using some of the provided media from the tutorial Game Level. And, to take it one step further, I made the third person perspective from converting the Beast Hunt or monster hunt code in the Dark Basic tutorials. This could be alot of help to someone out there.
// 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 )
{
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
//Set our directory to the media folder
SetCurrentDirectory ("media");
dbLoadObject ( "universe.dbo", 1);
dbSetObjectLight (1, 0);
//Load our skybox
dbLoadObject ("skybox2.x",2 );
dbSetObjectLight (2,0);
dbSetObjectTexture (2,3,2);
dbScaleObject (2,5000,5000,5000);
//Make our character (sphere)
dbMakeObjectSphere (3, 25);
dbPositionObject (3, 434, 42, -517);
//Position the camera
dbMakeCamera (1);
// our main loop
while ( LoopGDK ( ) )
{
//Stores the Y coordinate of the sphere
float AYf = dbObjectAngleY (3);
//Rotates the sphere if keys are pressed
if (dbLeftKey()) dbYRotateObject (3, dbWrapValue(AYf+0.5f) );
if (dbRightKey()) dbYRotateObject (3, dbWrapValue(AYf-0.5f) );
//Moves the sphere if keys are pressed
if (dbUpKey()) dbMoveObject (3,5);
if (dbDownKey()) dbMoveObject (3,-5);
//store the X Z positions of the object
float Xf = dbObjectPositionX (3);
float Zf = dbObjectPositionZ (3);
//get the coordinates behind the sphere for camera positioning
float cZf = dbNewZValue(Zf, AYf - 180,100);
float cXf = dbNewXValue(Xf, AYf - 180,100);
//Position the camera behind the sphere
dbPositionCamera(1,cXf, 50, cZf);
//Point the camera at the sphere
dbPointCamera(1,Xf,50,Zf);
// update the screen
dbSync ( );
}
// return back to windows
return;
}
The only changes you really have to make is you have to know that variables are not declared the same way that they are in db by coding something like
aY# = Object Value Y
Instead, you have to delcare what type it is with its name such as
float aYf = dbObjectValueY (obj int); (ALWAY FOLLOW WITH SEMI-COLON);
Another thing to keep in mind is you always have to assing an index for your objects you are creating. SO, no more Position Camera XYZ, instead its
dbPositionCamera ( obj int, X, Y, Z)
that was my biggest problem making this work
Im thinking about putting up a website for just GDK tutorials. If any of you masters out there are willing to through together some tutorials for me, let me know.
typos...