Game Development Reference
In-Depth Information
BaseGameLogic , and any game-specific processing that needs to occur is put in the
TeapotWarsLogic class. Let
'
s take a look at the TeapotWarsLogic class:
class TeapotWarsLogic : public BaseGameLogic
{
protected:
std::list<NetworkEventForwarder*> m_networkEventForwarders;
public:
TeapotWarsLogic();
virtual
TeapotWarsLogic();
˜
// Update
virtual void VSetProxy();
virtual void VMoveActor(const ActorId id, Mat4x4 const &mat);
// Overloads
virtual void VChangeState(BaseGameState newState);
virtual void VAddView(shared_ptr<IGameView> pView,
ActorId actorId=INVALID_ACTOR_ID);
virtual shared_ptr<IGamePhysics> VGetGamePhysics(void) {return m_pPhysics;}
// set/clear render diagnostics
void ToggleRenderDiagnostics() {m_RenderDiagnostics = !m_RenderDiagnostics;}
// event delegates
void RequestStartGameDelegate(IEventDataPtr pEventData);
void GameStateDelegate(IEventDataPtr pEventData);
void RemoteClientDelegate(IEventDataPtr pEventData);
void NetworkPlayerActorAssignmentDelegate(IEventDataPtr pEventData);
void NewGameDelegate(IEventDataPtr pEventData);
protected:
virtual bool VLoadGameDelegate(TiXmlElement* pLevelData);
private:
void RegisterAllDelegates(void);
void RemoveAllDelegates(void);
void CreateNetworkEventForwarder(const int socketId);
void DestroyAllNetworkEventForwarders(void);
};
Much like TeapotWarsApp , this class mostly overrides virtual functions to change
or augment the behavior of the game logic. One big difference between this class
and the application layer is that TeapotWarsLogic defines a number of delegate
functions. These are the listener functions for various game events that it needs to
Search WWH ::




Custom Search