When i run my program, the window just freezes, and i cant even click the x on it, i have to ctrl+alt+delete it away, heres my code:
Main.cpp:
#include "DarkGDK.h"
#include "player.h"
#include "skybox.h"
void DarkGDK( void )
{
dbSyncOn();
dbSyncRate(60);
dbAutoCamOff();
Skybox s("skybox.x", 3000, 3000, 3000);
Player p(100);
dbSetCameraRange(5000, 5000);
float fCameraAngleX = 0.0f;
float fCameraAngleY = 0.0f;
while(LoopGDK())
{
dbMakeMatrix(4, 10000, 10000, 100, 100);
p.lControl(1, fCameraAngleX, fCameraAngleY);
p.lUpdate_stats();
dbSync();
}
return;
}
t_entity.h:
#ifndef T_ENTITY_
#define T_ENTITY_
#include "DarkGDK.h"
class t_entity {
int id;
float posX;
float posY;
float posZ;
float rotX;
float rotY;
float rotZ;
public:
t_entity(int iID, LPSTR lpFileName);
~t_entity(void);
int ID(void){ return id; }
void lUpdate_stats(void);
};
#endif /* T_ENTITY_ */
t_entity.cpp:
#include "DarkGDK.h"
#include "t_entity.h"
t_entity::t_entity(int iID, LPSTR lpFileName)
:id(iID)
{
dbLoadObject(lpFileName, id);
}
t_entity::~t_entity(void)
{
dbDeleteObject(id);
}
void t_entity::lUpdate_stats(void)
{
posX = dbObjectPositionX(id);
posY = dbObjectPositionY(id);
posZ = dbObjectPositionZ(id);
rotX = dbObjectAngleX(id);
rotY = dbObjectAngleY(id);
rotZ = dbObjectAngleZ(id);
}
player.h:
#ifndef PLAYER_
#define PLAYER_
#include "t_entity.h"
class Player : public t_entity {
int health;
public:
Player(int health);
void lControl(float mSpeed, float cameraAngleX, float cameraAngleY);
};
#endif /* PLAYER_ */
player.cpp:
#include "player.h"
#include "t_entity.h"
#include "g_def.h"
Player::Player(int health)
:health(health), t_entity(999, "nothing.x")
{
}
void Player::lControl(float mSpeed, float cameraAngleX, float cameraAngleY)
{
if(dbKeyState(KEY_W))
dbMoveCamera(mSpeed);
if(dbKeyState(KEY_A))
dbMoveCameraLeft(0, mSpeed);
if(dbKeyState(KEY_S))
dbMoveCamera(-mSpeed);
if(dbKeyState(KEY_D))
dbMoveCameraRight(0, mSpeed);
cameraAngleX = dbWrapValue(cameraAngleX + dbMouseMoveY());
cameraAngleY = dbWrapValue(cameraAngleY + dbMouseMoveX());
dbXRotateCamera(cameraAngleX);
dbYRotateCamera(cameraAngleY);
}
skybox.h:
#ifndef SKYBOX_
#define SKYBOX_
#include "t_entity.h"
class Skybox : public t_entity {
public:
Skybox(LPSTR lpFileName, float scaleX, float scaleY, float scaleZ);
};
#endif
skybox.cpp:
#include "skybox.h"
int getMaxID()
{
int temp = 1;
while(!dbObjectExist(temp))
{
temp++;
}
return temp;
}
Skybox::Skybox(LPSTR lpFileName, float scaleX, float scaleY, float scaleZ)
:t_entity(getMaxID(), lpFileName)
{
dbScaleObject(ID(), scaleX, scaleY, scaleZ);
}
g_def.h:
#ifndef G_DEF_
#define G_DEF_
/* All these codes were
* written by Jason P
* Sage, all credit
* goes to him.
*/
#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
#endif /* G_DEF_ */
Any help would be appreciated