Alright, I thought I understood how to use classes, let me show you what i'm doing:
NPC Class:
class NPC {
public:
int objnum;
int health;
NPC( int h, int x, int y, int z )
{
dbLoadObject ( "tiger.x", npcnum );
health = h;
objnum = npcnum;
dbMakeObjectSphere( npcnum, 1 );
dbPositionObject( npcnum, x, y, z );
npcnum++;
}
};
Now i'm trying to print something from the class:
if ( dbMouseClick() == 1 )
{
int selobj = dbPickObject(dbMouseX(),dbMouseY(),1,10);
if ( selobj <= 500 && selobj >= 1000 )
{
int selh = NPC[selobj]::health;
char stuff1 [ 256 ] = "NPC ID = ";
strcat ( stuff1, dbStr ( selobj ) );
dbText ( 0, 0, stuff1 );
char stuff2 [ 256 ] = "NPC Health = ";
strcat ( stuff2, dbStr ( selh ) );
dbText ( 0, 10, stuff2 );
}
Well I get a few errors when I try to compile:
1>c:\users\administrator\desktop\3d rpg\3d rpg\3d rpg\functions.h(78) : error C2275: 'NPC' : illegal use of this type as an expression
1> c:\users\administrator\desktop\3d rpg\3d rpg\3d rpg\classes.h(1) : see declaration of 'NPC'
1>c:\users\administrator\desktop\3d rpg\3d rpg\3d rpg\functions.h(78) : error C2039: 'health' : is not a member of '`global namespace''
1>c:\users\administrator\desktop\3d rpg\3d rpg\3d rpg\functions.h(78) : error C2146: syntax error : missing ';' before identifier 'health'
1>c:\users\administrator\desktop\3d rpg\3d rpg\3d rpg\functions.h(78) : error C2065: 'health' : undeclared identifier