// Dark GDK - The Game Creators - www.thegamecreators.com
// include the Dark GDK header
#include "DarkGDK.h"
#include "dinput.h"
#include "Start Up.h"
#include "controls.h"
void DarkGDK ( void )
{
Start();
// entry point for the application
// switch on sync rate and set to a maximum of 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
// we are going to use a skybox in this demo and it will
// be scaled up to quite a large size, this will initially
// result in it being outside of the cameras default range
// therefore it will not be drawn, to adjust this we simply
// increase the cameras range
dbSetCameraRange ( 1.0f, 30000.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 );
// in this call we're telling the terrain that its diffuse texture
// will come from image 1 and its detail texture will come from
// image 2
dbSetTerrainTexture ( 1, 1, 2 );
// once we have set all properties of the terrain we can build it,
// at this point it gets created and added into your world
dbBuildTerrain ( 1 );
// with the terrain in place we can now load a skybox
dbLoadObject ( "skybox2.x", 2 );
// we dont need it to respond to light so switch light off
dbSetObjectLight ( 2, 0 );
// make the skybox much larger
dbScaleObject ( 2, 3000, 3000, 3000 );
dbLoadObject ( "H-AK47-Static.x", 10 );
dbScaleObject(10,1000,1000,1000);
// position the camera
dbPositionCamera ( 385, 23, 100 );
dbPositionObject(10,dbCameraPositionX(),dbCameraPositionY(),dbCameraPositionZ());
// adjust texture properties of sky box
dbSetObjectTexture ( 2, 3, 1 );
//dbLockObjectOn ( 10 );
float fCameraAngleX = 0.0f;
float fCameraAngleY = 0.0f;
// now onto our main loop
while ( LoopGDK ( ) )
{
// let the user move the camera around with the arrow keys
dbControlCameraUsingArrowKeys ( 0, 2.0f, 2.0f );
// find the ground height of the terrain
float fHeight = dbGetTerrainGroundHeight ( 1, dbCameraPositionX ( ), dbCameraPositionZ ( ) );
// reposition the camera so it is directly above the ground
dbPositionCamera ( dbCameraPositionX ( ), fHeight + 15.0f, dbCameraPositionZ ( ) );
// update the terrain
dbUpdateTerrain ( );
// create a rotation axis based on mouse movement
fCameraAngleX = dbWrapValue ( fCameraAngleX + dbMouseMoveY ( ) * 0.04f );
fCameraAngleY = dbWrapValue ( fCameraAngleY + dbMouseMoveX ( ) * 0.04f );
// rotate camera
dbXRotateCamera ( fCameraAngleX );
dbYRotateCamera ( fCameraAngleY );
dbPositionObject(10,dbCameraPositionX()+1,dbCameraPositionY(),dbCameraPositionZ());
//controls();
// update the screen
dbSync ( );
}
}
#ifndef START_UP
#define START_UP
#include "DarkGDK.h"
//Declarations
void SetDisplay();
void SetBasicsAndLoad();
/*Get Program Running */ void Start()
{
SetDisplay();
SetBasicsAndLoad();
//Colors();
}
/* Find Highest Rez */ void SetDisplay()
//Cycle Through 11 Resolution Modes and Find The Highest
{
if (dbCheckDisplayMode ( 1680, 1050, 32 ))
{
dbSetDisplayMode ( 1680, 1050, 32 );
//break;
}
else if (dbCheckDisplayMode ( 1600, 1024, 32 ))
{
dbSetDisplayMode ( 1600, 1024, 32 );
//break;
}
else if (dbCheckDisplayMode ( 1440, 900, 32 ))
{
dbSetDisplayMode ( 1440, 900, 32 );
//break;
}
else if (dbCheckDisplayMode ( 1400, 1050, 32 ))
{
dbSetDisplayMode ( 1400, 1050, 32 );
//break;
}
else if (dbCheckDisplayMode ( 1280, 1024, 32 ))
{
dbSetDisplayMode ( 1280, 1024, 32 );
//break;
}
else if (dbCheckDisplayMode ( 1280, 960, 32 ))
{
dbSetDisplayMode ( 1280, 960, 32 );
//break;
}
else if (dbCheckDisplayMode ( 1280, 800, 32 ))
{
dbSetDisplayMode ( 800, 600, 32 );
//break;
}
else if (dbCheckDisplayMode ( 1280, 720, 32 ))
{
dbSetDisplayMode ( 1280, 720, 32 );
//break;
}
else if (dbCheckDisplayMode ( 1152, 864, 32 ))
{
dbSetDisplayMode ( 1152, 864, 32 );
//break;
}
else if (dbCheckDisplayMode ( 1024, 768, 32 ))
{
dbSetDisplayMode ( 1024, 768, 32 );
//break;
}
else if (dbCheckDisplayMode ( 800, 600, 32 ))
{
dbSetDisplayMode ( 800, 600, 32 );
//break;
}
}
/* Create and Set Basics */ void SetBasicsAndLoad()
{
//Create Window, Set Title, Set Loading Text, Set Sync Rate
//Hide Mouse
dbHideMouse();
dbPositionMouse(0,0);
//Maximize window and display start up text
dbSetWindowTitle("The Epic FPS by Rei Kumar");
dbMaximiseWindow();
}
#endif