Game Development Reference
In-Depth Information
Figure 80 - Model View Controller relationship.
A very important trait of the MVC pattern in modern game UI is that by separating the
data, the controlling and the rendering of a UI element, we open the door towards having a
multithreadedarchitecture.Multithreadedgameswillusuallyruntherenderingofthegame
on its own thread and the game update will run in another or several other threads, we can
update the model continuously in a thread and at some point in the game's execution we
will synchronize the data with the rendering thread, displaying the latest state of the data
model.
The model view controller is used in the example code to create different user interface
elements, health bars, counters, damage feedback, etc. There is no explicit model class be-
cause in a game the model is the player's data, the view may query or poll a snapshot of
the data and the controller will update the data according to the player's actions.
Search WWH ::




Custom Search