Is it well done? (Object Hierarchy)

Started by
4 comments, last by Lestat3D 22 years, 5 months ago
I''m working on an RPG game on VC++ and DX8, and I would to know if I have to write my own Direct3DRM classes, I''ve started with a hierarchy like as follows (it''s just a diagram): class CCamera { //''Look-at'' Vector //''Up'' Vector //Position Vector //Set-Get Camera Methods } class CCharacter { //CMesh Object //Position Vector //''Look-at'' Vector //Position Vector (Relative to Scenario) //Set-Get Mesh Methods //Animation Methods //Talking Methods //Sounds } class CScenario { //CMesh Objects //Position Methods //CCharacters Collection //CCameras Collection //Set-Get Mesh Methods //Animation Methods //Natural Events Methods } class CCollisionManager { //Information About Coordinates and Meshes //CallBack functions that manages collisions between CCharacters } class CGame { //CMenu Object //CPlayers Collection //CCharacters Collection //... } I want to know if I am doing sonething bad in my objects hierarchy. Tnxs a lot.
Advertisement
Looks pretty good

Instead of call-backs you can use observers, and/or interface pointers.

Anything that the collision mangager needs to deal with could support a ''ICollisionObject'' interface, for instance.

Magmai Kai Holmlor
- Not For Rent
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Do you have a link about observer? I hear about them, but i don''t know what they are.

Why English rules?? C pas très malin tout ça!
_______________
Jester, studient programmerThe Jester Home in French
If you''re familar with Java, they call them ''Listeners''.

  //In some fileinterface ISomeObjectObserver	{	HRESULT OnSomeEvent(ISomeObject* pObj, ...);	}class CSomeObject : public ISomeObject	{	AddObserver(ISomeObjectObserver* pOb)		{		m_pObserver = pOb;		}	HRESULT SomeEvent()		{		return m_pObserver->OnSomeEvent(this, ...);		}	};//In some other fileclass CMyClass : public ISomeObjectObserver	{	HRESULT OnSomeEvent(ISomeObject* pObj, ...)		{		cout<<"SomeObject ("<<pObj<<") fired SomeEvent"<<endl;		}	};  

This decouples the event handling code from the event firing code, which makes it easy to make more classes the can send/receive ISomeObject events via the Observer interface.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Thanks a lot for your hints.
Yes, I''m familiarized with java, but I don''t know how to implemet it in VC++, could you help me with it?
I see the basis, I mean.

Why English rules?? C pas très malin tout ça!
_______________
Jester, studient programmerThe Jester Home in French

This topic is closed to new replies.

Advertisement