Ok I'm new to both DarkGDK and C++ so i'm sure i'm doing this all wrong.
All I want to do is be able to create an instances of a "man"'s with their own properties so they can be controlled seperatly at any time. The "Man" has his own 3D model so I will need to duplicate the model for that one "Man".
Now the problem is in Man::Create() it won't let me make a Man because I'm using a variable so I can keep a array of all the "Man"'s.
The full code is here:
#include "DarkGDK.h"
class Man
{
public:
bool selected;
int obj;
int model;
int mode;
void Select();
int Create();
};
int TOTALMEN;
void Man::Select()
{
int MOUSECLICKBUTTON;
MOUSECLICKBUTTON = dbMouseClick();
if (MOUSECLICKBUTTON == 1)
{
if(dbPickObject(dbMouseX(),dbMouseY(),1,10) == model)
{
if (selected == false)
{
dbCircle ( dbMouseX(), dbMouseY(), 30 );
selected = true;
}
else
{
selected = false;
}
}
}
return;
}
int Man::Create()
{
int ono;
int TRR;
TRR = TOTALMEN;
dbInstanceObject(TRR,2);
Man Guy[TRR];
return ono;
}
void CameraControl ( void ) // Control The in-game camera
{
int CamSpeed = 4; // Camera Movement Speed
//Right
if ( dbMouseX ( ) > dbScreenWidth ( ) - (dbScreenWidth ( )/50) )
dbPositionCamera ( dbCameraPositionX()+CamSpeed, dbCameraPositionY(), dbCameraPositionZ()+CamSpeed );
//Left
if ( dbMouseX ( ) < (dbScreenWidth ( )/50) )
dbPositionCamera ( dbCameraPositionX()-CamSpeed, dbCameraPositionY(), dbCameraPositionZ()-CamSpeed );
// Up
if ( dbMouseY ( ) < (dbScreenHeight ( )/50) )
dbPositionCamera ( dbCameraPositionX()-CamSpeed, dbCameraPositionY(), dbCameraPositionZ()+CamSpeed );
// Down
if ( dbMouseY ( ) > dbScreenHeight ( ) - (dbScreenHeight ( )/50) )
dbPositionCamera ( dbCameraPositionX()+CamSpeed, dbCameraPositionY(), dbCameraPositionZ()-CamSpeed );
if ( dbKeyState( 13 ) == 1 ) // '+' Key
dbMoveCamera ( CamSpeed );
if ( dbKeyState( 12 ) == 1 ) // '-' Key
dbMoveCamera ( -CamSpeed);
if ( dbKeyState( 11 ) == 1 ) // '0' Key
dbPitchCameraDown ( CamSpeed );
if ( dbKeyState( 10 ) == 1 ) // '9' Key
dbPitchCameraDown ( -CamSpeed );
if ( dbKeyState( 9 ) == CamSpeed ) // '8' Key
dbYRotateCamera ( dbCameraAngleY()-CamSpeed );
if ( dbKeyState( 8 ) == 1 ) // '7' Key
dbYRotateCamera ( dbCameraAngleY()+CamSpeed );
return;
}
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
dbBackdropOn();
// Set to fullscreen Mode
dbSetDisplayMode (1680,1050,32);
dbSetWindowLayout(0,0,0);
dbMaximizeWindow();
// set our random seed to a value from the timer, this will help
// to ensure each time we run our program the random values appear
// more random
dbRandomize ( dbTimer ( ) );
dbLoadObject( "Resources/Level2.dbo", 1 );
dbLoadObject( "Resources/Man.x", 2 );
Man Guy[10];
//Guy[0].Create()
// move our camera back so we can view the objects
dbPositionCamera ( 50, 290, -20 );
dbRotateCamera (45,-45,dbCameraAngleZ());
dbColorBackdrop(dbRGB(0,0,0));
// now we come to our main loop, we call LoopGDK so some internal
// work can be carried out by the GDK
while ( LoopGDK ( ) )
{
// display some text on screen
dbText ( 0, 0, "Use the up and down arrow keys to move the camera" );
CameraControl( ); // Make the camera move
Guy[0].Select();
// here we make a call to update the contents of the screen
dbSync ( );
}
// before quitting delete our objects
for ( int i = 1; i < 50; i++ )
dbDeleteObject ( i );
// and now everything is ready to return back to Windows
return;
}
Any sort of help or code would be very much appreciated!!!