To put it short, arrays do not do the best job in my situation, tried to switch one aspect of my game over to classes, don't work, get these errors when I try to compile
fat errors:
1>c:\users\administrator\desktop\3d rpg\3d rpg\3d rpg\declarations.h(52) : error C2864: 'tplayer::ModelNumber' : only static const integral data members can be initialized within a class
1>c:\users\administrator\desktop\3d rpg\3d rpg\3d rpg\declarations.h(53) : error C2864: 'tplayer::health' : only static const integral data members can be initialized within a class
1>c:\users\administrator\desktop\3d rpg\3d rpg\3d rpg\declarations.h(54) : error C2864: 'tplayer::level' : only static const integral data members can be initialized within a class
1>c:\users\administrator\desktop\3d rpg\3d rpg\3d rpg\declarations.h(55) : error C2864: 'tplayer::attack' : only static const integral data members can be initialized within a class
1>c:\users\administrator\desktop\3d rpg\3d rpg\3d rpg\declarations.h(56) : error C2864: 'tplayer::defence' : only static const integral data members can be initialized within a class
1>c:\users\administrator\desktop\3d rpg\3d rpg\3d rpg\declarations.h(57) : error C2864: 'tplayer::LastAttackTime' : only static const integral data members can be initialized within a class
1>c:\users\administrator\desktop\3d rpg\3d rpg\3d rpg\declarations.h(58) : error C2864: 'tplayer::SelectedNPC' : only static const integral data members can be initialized within a class
1>c:\users\administrator\desktop\3d rpg\3d rpg\3d rpg\declarations.h(59) : error C2864: 'tplayer::CanAttack' : only static const integral data members can be initialized within a class
1>c:\users\administrator\desktop\3d rpg\3d rpg\3d rpg\declarations.h(60) : error C2864: 'tplayer::name' : only static const integral data members can be initialized within a class
1>c:\users\administrator\desktop\3d rpg\3d rpg\3d rpg\functions.h(264) : error C2352: 'tplayer::Attack' : illegal call of non-static member function
1> c:\users\administrator\desktop\3d rpg\3d rpg\3d rpg\declarations.h(70) : see declaration of 'tplayer::Attack'
1>c:\users\administrator\desktop\3d rpg\3d rpg\3d rpg\functions.h(306) : error C2597: illegal reference to non-static member 'tplayer::SelectedNPC'
1>c:\users\administrator\desktop\3d rpg\3d rpg\3d rpg\functions.h(311) : error C2597: illegal reference to non-static member 'tplayer::SelectedNPC'
1>c:\users\administrator\desktop\3d rpg\3d rpg\3d rpg\main.cpp(18) : error C2352: 'tplayer::Can_Attack' : illegal call of non-static member function
1> c:\users\administrator\desktop\3d rpg\3d rpg\3d rpg\declarations.h(62) : see declaration of 'tplayer::Can_Attack'
yeah those were like the compiller kicking me in the face.
Here is the class:
class tplayer {
public:
int ModelNumber = 3;
int health = 100;
int level = 1;
int attack = 15;
int defence = 20;
int LastAttackTime = 0;
int SelectedNPC = -1;
bool CanAttack = true;
char name = "sucka fish";
void Can_Attack ( int curtime )
{
if ( curtime >= LastAttackTime )
{
CanAttack = true;
}
}
int Attack ( int curtime )
{
if ( CanAttack == true )
{
LastAttackTime = curtime;
CanAttack = false;
npcs[SelectedNPC][1] = npcs[SelectedNPC][1] - 10;
return 10;
}
}
};
And here are the various areas i'm trying to use it:
if ( dbSpaceKey() == 1 )
{
if ( player[6] == 1 && player[7] > -1 )
{
//Attack_Function(player[7]);
tplayer::Attack ( seconds );
}
}
if ( dbMouseClick() == 1 )
{
int selobj = dbPickObject(dbMouseX(),dbMouseY(),1,1000);
i = 0;
strcat ( stuff19, dbStr ( selobj ) );
dbText ( 0, 50, stuff19 );
if ( selobj >= 500 && selobj <= 1000 )
{
//player[7] = selobj-500;
tplayer::SelectedNPC = selobj-500;
}
else
{
//player[7] = -1;
tplayer::SelectedNPC = -1;
}
}
while ( LoopGDK ( ) )
{
seconds = time ( 0 );
tplayer::Can_Attack ( seconds );
//Player_Update ( );
//Net_Messages ( );
//Net_Send ( );
Camera_Control ( );
Player_Control ( );
Screen_Print ( );
moveObject ( 3, 0 );
Sprite_GUI ( );
NPC_Respawner ( );
dbSync ( );
}
I've read multiple tutorials on classes, I cant even use '.''s to access my variables.
I just dont get it...
I <3 C++ & Dark GDK 4 2 maek mai gamezorz! =D