Game Development Reference
In-Depth Information
'
There
the NetworkGameView . This is a
fake view that fools the authoritative game server into thinking someone is sitting
right there playing the game, instead of a few hundred milliseconds by photon away.
As you can see, it
s one last class you need to know about
'
s not much more than a pretty face.
class NetworkGameView : public IGameView
{
public:
// IGameView Implementation - everything is stubbed out.
virtual HRESULT VOnRestore() { return S_OK; }
virtual void VOnRender(double fTime, float fElapsedTime) { }
virtual void VOnLostDevice() { }
virtual GameViewType VGetType() { return GameView_Remote; }
virtual GameViewId VGetId() const { return m_ViewId; }
virtual void VOnAttach(GameViewId vid, ActorId aid)
{ m_ViewId = vid; m_PlayerActorId = aid; }
virtual LRESULT CALLBACK VOnMsgProc( AppMsg msg ) { return 0; }
virtual void VOnUpdate( int deltaMilliseconds ) { };
void SetPlayerActorId(ActorId actorId) { m_ActorId = actorId; }
void AttachRemotePlayer(int sockID);
int HasRemotePlayerAttached() { return m_SockId != -1; }
NetworkGameView(int sockId)
protected:
GameViewId m_ViewId;
ActorId m_ActorId;
int m_SockId;
};
NetworkGameView::NetworkGameView()
{
m_SockId = -1;
m_ActorId = INVALID_ACTOR_ID;
IEventManager::Get()->VAddListener(
MakeDelegate(this, &NetworkGameView::NewActorDelegate),
EvtData_New_Actor::sk_EventType);
}
The constructor registers to listen for a single event when new actors are created. For
the game-specific events, you
ll create a NetworkEventForwarder class both on the
server side and on the client side to listen for events and forward them to the other
computer across the Internet.
'
Search WWH ::




Custom Search