Is it well done? (Object Hierarchy)
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.
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
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
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!
Why English rules?? C pas très malin tout ça!
If you''re familar with Java, they call them ''Listeners''.
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.
//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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement