Ok, I've been having a few problems, as I've been transfering from DBPro into the DarkSDK I've had problems with muliple files, I'm using the Microsoft Visual C++ .NET compiler. I've gotten the compiler set up and made some basic programs to test it. However when I've been trying to add a second file to the program with a class and a few global constants, it'll compile fine if I don't use the class, however when I try to make an object of the class it keeps saying that the class doesn't exist and so on and so forth.
I guess the best way to explain would be to show you the files I've been working with, note that the second one is quite long...
#include <DarkSDK.h>
//#include <string.h>
//#include <stdio.h>
void DarkSDK()
{
char fpsText[255];
DBSDKgeneralInput UIN;
float rotSpeed = 0.1f;
dbSyncOn();
dbSyncRate(0);
dbAutoCamOff();
dbPositionCamera(50,50,50);
dbPointCamera(0,0,0);
dbMakeObjectBox(1,10,10,10);
dbSync();
while(LoopSDK())
{
dbYRotateObject(1,dbObjectAngleY(1)+rotSpeed);
sprintf (fpsText, "Screen FPS: %d" , dbScreenFPS());
if(UIN.keyJustReleased(C_UPKEY)) rotSpeed += 0.05f;
if(UIN.keyJustReleased(C_DOWNKEY)) rotSpeed -= 0.05f;
dbText(0,0,fpsText);
UIN.update();
dbSync();
}
}
and the second:
#include <DarkSDK.h>
//--------------------------------------------------------------------------
//######################### General Key Info #############################
//--------------------------------------------------------------------------
//Constants for the mouse buttons
const int C_LMB = -1;
const int C_RMB = -2;
const int C_MMB = -3;
const int C_LEFTB = -4;
//Constants for keys (scancodes)
const int C_UPKEY = 200;
const int C_DOWNKEY = 208;
const int C_LEFTKEY = 203;
const int C_RIGHTKEY = 205;
const int C_RETURNKEY = 28;
const int C_SPACEKEY = 57;
const int C_LEFTSHIFTKEY = 42;
const int C_RIGHTSHIFTKEY = 54;
const int C_LEFTCTRLKEY = 29;
const int C_RIGHTCTRLKEY = 157;
const int C_LEFTALTKEY = 56;
const int C_RIGHTALTKEY = 184;
const int C_BACKSPACEKEY = 14;
const int C_CAPSLOCKKEY = 58;
const int C_TABKEY = 15;
const int C_INSERTKEY = 210;
const int C_DELETEKEY = 211;
const int C_HOMEKEY = 199;
const int C_ENDKEY = 207;
const int C_PAGEUPKEY = 201;
const int C_PAGEDOWNKEY = 209;
const int C_PAD1KEY = 77;
const int C_PAD2KEY = 78;
const int C_PAD3KEY = 79;
const int C_PAD4KEY = 74;
const int C_PAD5KEY = 75;
const int C_PAD6KEY = 76;
const int C_PAD7KEY = 71;
const int C_PAD8KEY = 72;
const int C_PAD9KEY = 73;
const int C_PAD0KEY = 82;
const int C_PADRETURNKEY = 156;
const int C_PADDELETEKEY = 83;
const int C_PADPLUSKEY = 78;
const int C_PADMINUSKEY = 74;
const int C_F1KEY = 59;
const int C_F2KEY = 60;
const int C_F3KEY = 61;
const int C_F4KEY = 62;
const int C_F5KEY = 63;
const int C_F6KEY = 64;
const int C_F7KEY = 65;
const int C_F8KEY = 66;
const int C_F9KEY = 67;
const int C_F10KEY = 68;
const int C_F11KEY = 87;
const int C_F12KEY = 88;
//------ general keys ----------
const int C_WAVEKEY =41;
const int C_1KEY = 2;
const int C_2KEY = 3;
const int C_3KEY = 4;
const int C_4KEY = 5;
const int C_5KEY = 6;
const int C_6KEY = 7;
const int C_7KEY = 8;
const int C_8KEY = 9;
const int C_9KEY = 10;
const int C_0KEY = 11;
const int C_MINUSKEY = 12;
const int C_EQUALSKEY = 13;
const int C_QKEY = 16;
const int C_WKEY = 17;
const int C_EKEY = 18;
const int C_RKEY = 19;
const int C_TKEY = 20;
const int C_YKEY = 21;
const int C_UKEY = 22;
const int C_IKEY = 23;
const int C_OKEY = 24;
const int C_PKEY = 25;
const int C_RIGTBRACKETKEY = 26;
const int C_LEFTBRACKETKEY = 27;
const int C_LEFTSLASHKEY = 28;
const int C_AKEY = 30;
const int C_SKEY = 31;
const int C_DKEY = 32;
const int C_FKEY = 33;
const int C_GKEY = 34;
const int C_HKEY = 35;
const int C_JKEY = 36;
const int C_KKEY = 37;
const int C_LKEY = 38;
const int C_COLONKEY = 39;
const int C_QUOTEKEY = 40;
const int C_ZKEY = 44;
const int C_XKEY = 45;
const int C_CKEY = 46;
const int C_VKEY = 47;
const int C_BKEY = 48;
const int C_NKEY = 49;
const int C_MKEY = 50;
const int C_COMMAKEY = 51;
const int C_PERIODKEY = 52;
const int C_RIGHTSLASHKEY = 53;
class DBSDKgeneralInput
{
public:
DBSDKgeneralInput(){};
~DBSDKgeneralInput(){};
void setup( void );
void update( void );
//functions preDeclared...
void clearKey( int keyNum );
bool keyJustPressed( int keyNum );
bool keyJustReleased( int keyNum );
bool keyHold( int keyNum );
bool keyReleased( int keyNum );
bool keyDown( int keyNum );
bool keyUp( int keyNum );
int keyDownTime( int keyNum );
private:
int PI_keysPressed[256][3];
int PI_mousePressed[5][3];
};
void DBSDKgeneralInput::setup( void ){}
void DBSDKgeneralInput::update( void )
{
int n = 0;
int mouseBtn = 0;
//update keyboard input
for(n = 1; n <= 255; n++)
{
PI_keysPressed[n][0] = PI_keysPressed[n][1];
PI_keysPressed[n][1] = dbKeyState(n);
if(keyJustPressed(n)) PI_keysPressed[n][2] = dbTimer();
if(keyJustReleased(n)) PI_keysPressed[n][2] = 0;
}
//now update mouse (a little more tricky...)
mouseBtn = dbMouseClick();
for(n = 1; n <= 4; n++)
{
PI_mousePressed[n][0] = PI_mousePressed[n][1];
PI_mousePressed[n][1] = 0;
}
if(mouseBtn >= 8){ PI_mousePressed[4][1] = 1; mouseBtn -= 8; }
if(mouseBtn >= 4){ PI_mousePressed[3][1] = 1; mouseBtn -= 4; }
if(mouseBtn >= 2){ PI_mousePressed[2][1] = 1; mouseBtn -= 2; }
if(mouseBtn >= 1){ PI_mousePressed[1][1] = 1; mouseBtn -= 1; }
//now update the timer part
for(n = 1; n <= 4; n++)
{
if(keyJustPressed(0-n)) PI_mousePressed[n][2] = dbTimer();
if(keyJustReleased(0-n)) PI_mousePressed[n][2] = 0;
}
}
void DBSDKgeneralInput::clearKey(int keyNum)
{
if(keyNum < 0)
{
keyNum = abs(keyNum);
PI_mousePressed[keyNum][0] = 0;
PI_mousePressed[keyNum][1] = 0;
PI_mousePressed[keyNum][2] = 0;
}
else
{
PI_keysPressed[keyNum][0] = 0;
PI_keysPressed[keyNum][0] = 0;
PI_keysPressed[keyNum][0] = 0;
}
}
bool DBSDKgeneralInput::keyJustPressed( int keyNum )
{
bool rtrn = false;
if(keyNum < 0)
{
keyNum = abs(keyNum);
if(PI_mousePressed[keyNum][1] == 1 && PI_mousePressed[keyNum][0] == 0) rtrn = true;
}
else
{
if(PI_keysPressed[keyNum][1] == 1 && PI_keysPressed[keyNum][0] == 0) rtrn = true;
}
return rtrn;
}
bool DBSDKgeneralInput::keyJustReleased( int keyNum )
{
bool rtrn = false;
if(keyNum < 0)
{
keyNum = abs(keyNum);
if(PI_mousePressed[keyNum][1] == 0 && PI_mousePressed[keyNum][0] == 1) rtrn = true;
}
else
{
if(PI_keysPressed[keyNum][1] == 0 && PI_keysPressed[keyNum][0] == 1) rtrn = true;
}
return rtrn;
}
bool DBSDKgeneralInput::keyHold( int keyNum )
{
bool rtrn = false;
if(keyNum < 0)
{
keyNum = abs(keyNum);
if(PI_mousePressed[keyNum][1] == 1 && PI_mousePressed[keyNum][0] == 1) rtrn = true;
}
else
{
if(PI_keysPressed[keyNum][1] == 1 && PI_keysPressed[keyNum][0] == 1) rtrn = true;
}
return rtrn;
}
bool DBSDKgeneralInput::keyReleased( int keyNum )
{
bool rtrn = false;
if(keyNum < 0)
{
keyNum = abs(keyNum);
if(PI_mousePressed[keyNum][1] == 0 && PI_mousePressed[keyNum][0] == 0) rtrn = true;
}
else
{
if(PI_keysPressed[keyNum][1] == 0 && PI_keysPressed[keyNum][0] == 0) rtrn = true;
}
return rtrn;
}
bool DBSDKgeneralInput::keyDown( int keyNum )
{
bool rtrn = false;
if(keyNum < 0)
{
keyNum = abs(keyNum);
if(PI_mousePressed[keyNum][1] == 1) rtrn = true;
}
else
{
if(PI_keysPressed[keyNum][1] == 1) rtrn = true;
}
return rtrn;
}
bool DBSDKgeneralInput::keyUp( int keyNum )
{
bool rtrn = false;
if(keyNum < 0)
{
keyNum = abs(keyNum);
if(PI_mousePressed[keyNum][0] == 1) rtrn = true;
}
else
{
if(PI_keysPressed[keyNum][0] == 1) rtrn = true;
}
return rtrn;
}
int DBSDKgeneralInput::keyDownTime( int keyNum )
{
int rtrn = 0;
if(keyNum < 0)
{
keyNum = abs(keyNum);
if(PI_mousePressed[keyNum][2] != 0) rtrn = dbTimer() - PI_mousePressed[keyNum][2];
}
else
{
if(PI_keysPressed[keyNum][2] != 0) rtrn = dbTimer() - PI_keysPressed[keyNum][2];
}
return rtrn;
}
Thanks!
CPU
[center]K-OS Battlefields
IS
///---///---///---UNDER CONSTRUCTION---\\\---\\\---\\\[center]