Slowburn
02-14-2006, 04:02 PM
Hi all, I have a question about the MVC Pattern.
# Model - Encapsulates core game data and functionality `domain logic`.
# View - obtains data from the Model and presents it to the user.
# Controller - receives and translates input to requests on the Model or the View
"The View generally has free access to the Model, but should not change the state of the Model. It [the View] can register itself to [the Model] receive notifications when the Model changes."
- Does this mean that the View should have a EventDispatcher Object within and the Model call objView.dispatchEvent()? or should the View call on the Model to recieve updates? objModel.getNewPlayerPosition()?
The reason I ask is cause I'm a little confused on how to properly implement this pattern on a Flash based game.
To be a little more clear: My game is tile-based, and the user presses Keys to have the Player perform actions.
In this pattern I believe that this is a proper method chain:
1. Controller: receives input via Keyboard and dispatches an Event to the Model.
objModel.movePlayerLeft();
2. The Model then performs the calculations and then sends those calcs to the view for rendering..?
objModel.internalCalcs() -> objView.movePlayerLeft();
3. The View then acts to call component methods
objGameBoard.movePlayerLeft()?
I'm not sure if I have this correct. Any help is appreciated.
Cheers.
# Model - Encapsulates core game data and functionality `domain logic`.
# View - obtains data from the Model and presents it to the user.
# Controller - receives and translates input to requests on the Model or the View
"The View generally has free access to the Model, but should not change the state of the Model. It [the View] can register itself to [the Model] receive notifications when the Model changes."
- Does this mean that the View should have a EventDispatcher Object within and the Model call objView.dispatchEvent()? or should the View call on the Model to recieve updates? objModel.getNewPlayerPosition()?
The reason I ask is cause I'm a little confused on how to properly implement this pattern on a Flash based game.
To be a little more clear: My game is tile-based, and the user presses Keys to have the Player perform actions.
In this pattern I believe that this is a proper method chain:
1. Controller: receives input via Keyboard and dispatches an Event to the Model.
objModel.movePlayerLeft();
2. The Model then performs the calculations and then sends those calcs to the view for rendering..?
objModel.internalCalcs() -> objView.movePlayerLeft();
3. The View then acts to call component methods
objGameBoard.movePlayerLeft()?
I'm not sure if I have this correct. Any help is appreciated.
Cheers.