Game design pattern question

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
moonshine721
Posts: 9
Joined: Sun May 07, 2006 2:22 am
Location: Dlut.Dalian.China

Game design pattern question

Post 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)
HI.I'm Chrisalane.Nice to meet many crazy game developer here.
Warchief
Posts: 204
Joined: Tue Nov 22, 2005 10:58 am

Post 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
}
CuteAlien
Admin
Posts: 9694
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post 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.
Post Reply