Reputation: 11
Game is written using MVC pattern. For each duck there is duck_view duck_controller and duck_model. Duck_controller is responsible for registering hit when the button(duck_view) is clicked. When duck hp equals 0 duck_controller makes button inVisible(duck killed). There is also game_state_model representing an amount of ducks in game. Who should change game_state_model when a duck dies since the duck_controller is responsible for killing the duck?
Upvotes: 0
Views: 49
Reputation: 20061
Strictly speaking the Controller, and the Controller should not alter the view.
Image from https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller
This does not mean your game should have 3 classes; the image is conceptual. For example, you probably don't want your controller modifying the model directly and instead use some service classes to process the changes. Likewise the model won't directly update the view; it would be better to have something listening for model changes to determine the game state that would then update the view.
Upvotes: 1