1
\$\begingroup\$

I want to learn how to develop a MVC pattern, but i can't find any site in where they focus it to Games and not to Browser / Windows calculator.

Would anyone please link me a tutorial of how to develop MVC patter for games?

Thank you very much

\$\endgroup\$
2

1 Answer 1

2
\$\begingroup\$

Take a look at Game Coding Complete. McShaffry makes use of the MVC architecture and explains its uses well.

The basic gist of it in terms of games is usually:

Model
This is your game logic. Game state changes, scripted events, rulesets, etc.

View
This is mainly the rendering aspect of the game. If you wanted to be cross-platform and support more graphics APIs, you'd just need to change the View portion of the game without touching any of the other code.

Controller
Pretty much what it sounds like. This section handles the input events that affect the game state (Model) and in turn what happens on screen (View). You can be a bit clever with this for AI, for example. You could have a PlayerController and an AIController that both send input events to the Model code.

Similarly, the View can be AI sensors in order to observe the environment to make decisions (a heavily subsidised version of the player's view).

Hope that helps.

\$\endgroup\$
1
  • \$\begingroup\$ I don't think McShaffry's architecture is MVC, nor does he claim this. It does reflect a similar separation of model and view that MVC does, and he has a three-way separation of concerns (the logic, view and application layers), but these three layers don't really align with model, view and controller. For example, user input goes to the application layer, then to the view layer, then the view sends signals to the logic layer (2nd ed, p. 229); in MVC, the path C->V->M is not allowed. \$\endgroup\$
    – Nate C-K
    Commented Apr 2, 2013 at 16:59

Not the answer you're looking for? Browse other questions tagged .