Jump to content
  • Advertisement
Sign in to follow this  

This topic is 4828 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to write a networked game and have come across Model View Controller as one possibility as to how to organise the entity management code. Part of the inspiration was this article on gamasutra : http://www.gamasutra.com/features/20050414/rouwe_01.shtml. These are my thoughts are so far : Model - subclassed for entity types - holds entity state eg position/rotatation/hits - it provides access functions to change these attributes. View - has a subclass for different entity types - holds mapping of meshes/sounds/animations/particle effects for given state - virtual init() and update() function implemented for each subclass Controller - has a subclass that processes player input (mouse/keyboard) and updates model. - another subclass will be for an AI/server controlled entity My questions Should the model check controller for updates or should controller update model during it's update phase. Which of these 3 classes should be 'master' class that manages constuction/destruction of all 3. What virtual functions should be in controller class - does the AI code for eaxmple reside in the controller class or is the AI class separate from contoller. Should the mouse/keyboard input code be in controller or separate. How do I account for the network controller - ie the client gets out of sync with the server and needs to adjust its position - does the network contoller take control of the controller or does it update the model directly. Is this the best architecture to use in this case. [Edited by - tonyhnz on June 1, 2005 8:21:20 AM]

Share this post


Link to post
Share on other sites
Advertisement
If the object's state is dictated by the remote server/node then I would only have a network controller, no local one. Local input would be sent to the server which would respond with the position updates. Later if you find this performs too poorly, you can add interpolation, and it ought to be clearer by then where to perform that interpolation.


Pet Peeve: MVC is an architecture not a pattern, you can tell because it's composed of several patterns (design patterns are atomic).

Share this post


Link to post
Share on other sites
I edited the pattern reference.

The complication with having the network controller control the player entity is that I want network spikes to be not noticed by the client. So if player is moving then the player should keep moving even if the server is unreachable for a period of time.
I was therefore thinking best approach would be local controller controls the player entity and it gets periodic validations of its position from server. If it gets out of sync with server then it has to adjust the local position to match. Also the local controller can only run for a certain time without server validation at which point it stops.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
This sounds like what UT does

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!