Page 1 of 1

Game design pattern question

Posted: Tue May 09, 2006 2:40 pm
by moonshine721
:oops: Sorry,I don't know if I shall post this kind of Qs here,but it really troubled me.
If I wanna create a FootballPlayer class,Shall I inhert from the irr::scene::Iscenenode class,and add some other functions to describe the behaviors of my FootballPlayer class,then implement it somewhere in my code?
Or I shall just implement a IScenenode pointer to my FBPlayer,And then use it as an attribute of my new FootballPlayer class?(the FootballPlayer class will not inhert from any class,it just supply a code encapsulation)

Posted: Tue May 09, 2006 3:31 pm
by Warchief
Second one.

Code: Select all

class IEntity {
  ISceneNode* model;
  // Common code for objects, or livings, or.... in your game
}


class CPlayer  :public IEntity
{
  // Player specific code
}

Posted: Tue May 09, 2006 3:39 pm
by CuteAlien
A good way to find the answer to that is to ask yourself it the class have a "is a" or "has a" relationship. So if the Football player "is a" scene node you would derive it from a scene node. You would have this relations if the football player class does for example enhance the scene-node class, maybe by adding functions to manipulate the modell.

But if your football player class does also keep data like energy, settings, etc, it
"has a" scene node representing the modell and then you should add that scene node to the football player class.