#include <DarkGDK.h>
//----------------------------------------------------------------------------
// Keyboard Scan Codes - Shorter Name Idea: FussPawn. :)
//----------------------------------------------------------------------------
#define Key_Escape 1
#define Key_A 30
#define Key_B 48
#define Key_C 46
#define Key_D 32
#define Key_E 18
#define Key_F 33
#define Key_G 34
#define Key_H 35
#define Key_I 23
#define Key_J 36
#define Key_K 37
#define Key_L 38
#define Key_M 50
#define Key_N 49
#define Key_O 24
#define Key_P 25
#define Key_Q 16
#define Key_R 19
#define Key_S 31
#define Key_T 20
#define Key_U 22
#define Key_V 47
#define Key_W 17
#define Key_X 45
#define Key_Y 21
#define Key_Z 44
#define Key_F1 59
#define Key_F2 60
#define Key_F3 61
#define Key_F4 62
#define Key_F5 63
#define Key_F6 64
#define Key_F7 65
#define Key_F8 66
#define Key_F9 67
#define Key_F10 68
#define Key_LeftSingleQuote 41
#define Key_1 2
#define Key_2 3
#define Key_3 4
#define Key_4 5
#define Key_5 6
#define Key_6 7
#define Key_7 8
#define Key_8 9
#define Key_9 10
#define Key_0 11
#define Key_Minus 12
#define Key_Equal 13
#define Key_BackSpace 14
#define Key_Tab 15
#define Key_LeftBracket 26
#define Key_RightBracket 27
#define Key_BackSlash 43
#define Key_Enter 28
#define Key_Caps 58
#define Key_LShift 42
#define Key_RShift 54
#define Key_SemiColon 39
#define Key_SingleQuote 40
#define Key_Comma 51
#define Key_Period 52
#define Key_ForwardSlash 53
#define Key_LWinKey 219
#define Key_LAlt 56
#define Key_RAlt 184
#define Key_RWinKey 220
#define Key_WinMenu 221
#define Key_LCntl 29
#define Key_RCntl 157
#define Key_PrintScreen 183
#define Key_ScrollLock 70
//#define Key_Pause 197
#define Key_Break 197
#define Key_Ins 210
#define Key_Del 211
#define Key_Home 199
#define Key_End 207
#define Key_PgUp 201
#define Key_PgDn 209
#define Key_UpArrow 200
#define Key_DownArrow 208
#define Key_LeftArrow 203
#define Key_RightArrow 205
#define Key_NumLock 69
#define Key_NumForwardSlash 181
#define Key_NumStar 55
#define Key_NumMinus 74
#define Key_NumPlus 78
#define Key_NumEnter 156
#define Key_NumPeriod 83
#define Key_Num1 79
#define Key_Num2 80
#define Key_Num3 81
#define Key_Num4 75
#define Key_Num5 76
#define Key_Num6 77
#define Key_Num7 71
#define Key_Num8 72
#define Key_Num9 73
#define Key_Num0 82
#define Key_SpaceBar 57
//----------------------------------------------------------------------------
float GroundHeight(
int p_ObjID,
float p_X,
float p_Z,
float p_HighestPointY,
float p_LowestPointY
){
float Height=dbIntersectObject(p_ObjID,p_X,p_HighestPointY,p_Z,p_X,p_LowestPointY,p_Z);
if(Height==0){
return 0;
}else{
return p_HighestPointY-Height;
};
};
void DarkGDK ( void )
{
int LandObjID=1;
float HighestPointY=1000;
float LowestPointY=-1000;
float MoveCameraAmount=1.0f;
float MoveCameraAmountFast=5.0f;
float TurnCameraAmount=1.0f;
dbAutoCamOff();
dbSyncOn ( );
dbSyncRate ( 60 );
dbLoadObject ("Demo Land.X", LandObjID);
dbSetWindowTitle ( "WiCKED Games Demo!" );
// Reenable this for your land... mine didn't need it
//dbRotateObject (LandObjID,270,0,0);
dbPositionCamera (50,50,100);
dbRotateCamera(0,0,0);
//dbSetCameraRange ( 10, 2000 ); // <<-- What's with the 10 ?????
dbSetCameraRange ( 0.1f, 2000 );
while ( LoopGDK ( ) )
{
// dbControlCameraUsingArrowKeys (0,5.0f,5.0f); <----- BAD BAD BAD
dbText (0,0, "Welcome! Use the WASD Keys to control the camera");
bool ShiftKeyPressed=(dbKeyState(Key_LShift)||dbKeyState(Key_RShift));
if(dbKeyState(Key_W)){
if(ShiftKeyPressed){
dbMoveCamera(MoveCameraAmountFast);
}else{
dbMoveCamera(MoveCameraAmount);
};
}else{
if(dbKeyState(Key_S)){
if(ShiftKeyPressed){
dbMoveCamera(-MoveCameraAmountFast);
}else{
dbMoveCamera(-MoveCameraAmount);
};
};
};
if(dbKeyState(Key_A)){
dbTurnCameraLeft(TurnCameraAmount);
}else{
if(dbKeyState(Key_D)){
dbTurnCameraRight(TurnCameraAmount);
};
};
float X=dbCameraPositionX();
float Y=dbCameraPositionY();
float Z=dbCameraPositionZ();
Y = 10+ GroundHeight(LandObjID,X,Z,HighestPointY, LowestPointY);
dbPositionCamera(X,Y,Z);
dbSync ( );
}
return;
}
There.... un comment the "dbRotateObject" line because I didn't need it. Have fun!