Skip to main content
GameDev.net gamedev.net
🔒 Locked

Model-View-Controller

Started by Sean_Seanston Dec 30, 2008 at 1:14 PM 0 replies 800+ views
Original Post
Sean_Seanston
Sean_Seanston
I stumbled across this article on game architecture while reading about controlling FPS: http://dewitters.koonsolo.com/gamemvc.html It all seems to make a lot of sense and is fairly easy to follow, but I've a few questions. 1. Does this mean that much or nearly all of the coding related to an entity coded this way (in this case a RaceCar) would be done through the Controller objects? What I mean is... if you wanted to spawn a RaceCar or something would it be handled by doing something like:
ObjectVector.push_back( new ObjectController );
And then once you had ObjectModel and Object View implemented you'd almost never really touch them again since the ObjectController class would be your interface to all aspects of the object? 2. Should the Controller class have a pointer to a Model and a pointer to a View? Sounds about right but I'm just trying to get this right in my head. 3. Is this model close to how you code or do you use something different? Is this one of the most common approaches to organizing game classes?
stonemetal
stonemetal
1. No, it means the outside world interacts with the model through controllers. Other items in the model work directly upon the race car(other race cars the barricades whatever.)

2. That is one implementation. I would say could, not should.

3 Somewhat, I don't follow it that closely but if you look closely at my code you would see similar logical boundaries as a natural result of separation of concerns.

A note about MVC it came out of writing business code where presentation was likely to change and the model (business logic) is the only reason for the app's existence. In games you are more likely to reuse everything but the model, so slavishly following MVC isn't all that great.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.