• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

## Recommended Posts

aka John M. Never give up. Never surrender!

##### Share on other sites
You could just have say, a CNode class, and inherit a generic CObject from it, adding some functionnalities common to all the graphical objects (like x and y position, etc).

Then inherit your CSprite from CObject (a CSprite wouldn''t have a DoAI() ). Then again, inherit a CCharacter and a CItem from CSprite.

That way you could add a DoAI in CCharacter and not in CItem. The way I''d do it would be to put a pure virtual method in the CCharacter class (like DoAction()) and inherit 2 other classes from CCharacter (pc and npc). In the Cpc class, it would be implemented to react to player input and, in the Cnpc one, to react to AI input.

I hope this makes at least a little sense... I''m not good at explaining that kind of stuff.. Also, this is kind of an overview. You''ll have to figure how to make this fit in your engine.

##### Share on other sites
(let me qualify this by saying that I have no real experience with this, and am in fact in the exact same boat as you..)

You don't need to include every method in the base class. If the need for the base class is just drawing, then all you really need to do is something like this:
  class CBase { public: virtual void Draw(void) = 0;};class CNPC : public CBase {// etc....

That way your linked list of all objects at a map position would work fine when you're drawing everything. Something like DoAI() would need only be in the NPC class.

*** EDIT ****
Hmmm, seems like you beat me to it, MuteAngel, by a good 5 or 6 minutes.. Huess that's what I get for drinking while posting a reply.. Kinda slows down the mind a little..

"What sounds to you like a big bloat of trashy old noise
is in fact the brilliant music of a genius--myself" ~ Iggy Pop

Edited by - the Dealy Lama on January 29, 2001 11:59:52 PM

##### Share on other sites
Yeah Lama but you provided an example... Much better than my would be explaination.

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627682
• Total Posts
2978614

• 13
• 12
• 10
• 12
• 22