MVC pattern for games

783058842956ab1b8f495cab05f64a37
0
sujay 101 May 01, 2012 at 13:00

Hello Guys,
Recently I read in a book related to Game coding that the games we code must follow the MVC Design Pattern.
Is it necessary that we strictly follow this pattern.
And do most of the games follow this pattern

4 Replies

Please log in or register to post a reply.

820ce9018b365a6aeba6e23847f17eda
0
geon 101 May 01, 2012 at 13:40

I have never read about games explicitly using the MVC pattern, but some sort of similar concept will usually be the result if the engine is at all well designed.

I think it is more common to have a component based approach, where a game object (like a monster) has an AI, a mesh renderer, a physics simulation etc.

8676d29610e6c98d6dd2d9c38528cd9c
0
alphadog 101 May 01, 2012 at 20:08

MVC is one of many general patterns to architect an app. MVC is simply a practice/pattern that makes you separate data, logic and presentation in a certain way. The reason that MVC isn’t strongly useful in all game subtypes is that, in most games, the Model is pretty close to the Presentation, esp. in 3D worlds. With a business-line app, the Model is often very different from the View, and there may be multiple Views of the same Model.

783058842956ab1b8f495cab05f64a37
0
sujay 101 May 02, 2012 at 14:18

@alphadog

MVC is one of many general patterns to architect an app. MVC is simply a practice/pattern that makes you separate data, logic and presentation in a certain way. The reason that MVC isn’t strongly useful in all game subtypes is that, in most games, the Model is pretty close to the Presentation, esp. in 3D worlds. With a business-line app, the Model is often very different from the View, and there may be multiple Views of the same Model.

Hi.You mean to say in 3d Worlds the model has only a single view or the model is equivalent to the view.Could you please give me an example regarding this.
Thanks.

8676d29610e6c98d6dd2d9c38528cd9c
0
alphadog 101 May 02, 2012 at 18:18

The Model exist to track a system-level representation of data, and the View exists to track a user-level representation. So, in a sense, I mean both. There is usually a limited number of views on the user side, and there’s little transformation between the two (ie. all that game world data becomes a fixed-size set of viewed pixels.)

This is different from the Observer pattern, from which MVC is modeled from. The Observer pattern is a little more universal, and can apply at the subsystem level or even on just one class. So, don’t confuse the purpose of the two.