I begun with Dark GDK yesterday, so I am useless...
I am trying to create a game based on the terrain example, currently I have a cube that can "walk" in any direction, but now I am trying to make it able to shoot and it the camera is weird(moves randomly when spawning a cube)
video:
http://teswo.dynalias.com/darkGDK.avi
code:
#include "DarkGDK.h"
void DarkGDK ( void )
{
dbText(10,10,"Teswo loading...");
dbSetWindowOff();
int pos1=385;
int pos2=23;
int pos3=200;
int rot=0;
int objid=10;
int shootsleep=0;
dbSyncOn ( );
dbSyncRate ( 60 );
dbMakeObjectCube(2, 8.0f);
dbPositionObject(2, pos1, pos2, pos3);
dbColorObject(2, dbRgb(255, 0, 0));
dbSetCameraRange ( 1.0f, 3000.0f );
dbLoadImage ( "texture.jpg", 1 );
dbLoadImage ( "detail.jpg", 2 );
dbSetupTerrain ( );
dbMakeObjectTerrain ( 1 );
dbSetTerrainHeightMap ( 1, "map.bmp" );
dbSetTerrainScale ( 1, 3.0f, 0.6f, 3.0f );
dbSetTerrainLight ( 1, 1.0f, -0.25f, 0.0f, 1.0f, 1.0f, 0.78f, 0.5f );
dbSetTerrainTexture ( 1, 1, 2 );
dbBuildTerrain ( 1 );
dbPositionCamera ( 385, 23, 100 );
dbSetObjectTexture ( 2, 3, 1 );
dbHideMouse();
bool shoot;
while ( LoopGDK ( ) )
{
if(dbUpKey())
{
dbMoveObject ( 2,1);
}
if(dbDownKey())
{
dbMoveObject ( 2,-1);
}
if(dbLeftKey())
{
rot--;
}
if(dbRightKey())
{
rot++;
}
dbSetCameraToFollow( dbObjectPositionX( 2 ), dbObjectPositionY( 2 ), dbObjectPositionZ( 2 ), dbObjectAngleY( 2 ), 10, 5, 20, 0 );
if(dbSpaceKey())
{
shoot=true;
}
if(shootsleep!=0)
shootsleep--;
if(shoot)
{
if(shootsleep==0)
{
dbMakeObjectCube(objid, 8.0f); // Create a cube: id = 1, Size = 8.0f
dbPositionObject(objid, dbObjectPositionX( 2 ), dbObjectPositionY( 2 ), dbObjectPositionZ( 2 )); // Position the cube.
dbColorObject(objid, dbRgb(0, 0, 255)); // Set its color to 'Red'
objid++;
shootsleep=120;
}
shoot=false;
}
dbYRotateCamera( dbObjectAngleY( 2 ) );
dbYRotateObject (2, rot*2);
float fHeight = dbGetTerrainGroundHeight ( 1, dbCameraPositionX ( ), dbCameraPositionZ ( ) );
float fHeight2 = dbGetTerrainGroundHeight ( 1, dbObjectPositionX(2), dbObjectPositionZ(2) );
dbPositionObject(2,dbObjectPositionX(2),fHeight2+8,dbObjectPositionZ(2) );
dbUpdateTerrain ( );
dbSync ( );
}
}