Advertisement

base/child classes

Started by June 10, 2001 08:41 AM
10 comments, last by mago 23 years, 8 months ago
quote:
Original post by Magmai Kai Holmlor

Carmack hates C++ and DirectX, or at least that''s what I gather from what I''ve read.




hmm. You are pretty late for the news. Carmack said in a voodooextreme interview that Directx 8 was now good, but he would still use opengl because portability matters a lot.

And he also said that Doom 3 would be written in C++. He mentionned that he might keep the renderer in C if he can easily include all the new features in it because he liked the architecture.
thanks for all the replies

I did something like this(of course the actual implementations have more members, private members, public accessors etc.):

class CAttribute
{
unsigned long value;
}

class CAttributeList: pubic std::list
{
unsigned long Insert(CAttribute&);
CAttribute& Find(unsigned long);
}

class CObject
{
bool valid;
int type;
CAttributeList* attributelist;

CObject(): valid(false), attributelist(new CAttributeList)
}

class CWeapon: CObject
{
CWeapon(name, damage,...)
{
InitializeAttributes();
SetAttributes();
SetType(TYPE_WEAPON)
valid = true;
};
}



so a weapon is constructed using a constructor from CWeapon, but it is registered in a list as a CObject. This way it can be in one list and when we want to see the attributes having just a CObject, we look at the type to see what to expect in the AttributeList...

mago
thanx for sharing

This topic is closed to new replies.

Advertisement