Reputation: 786
I was reading this article on using the MVC design pattern in game development, and I'd love to give it a go, but I'm a little confused as to how to dynamically create MVC objects. In the article they're talking about the creation of a shooter game, but what I don't understand is how a soldier could throw a grenade for example. It's easy enough for the soldier model to create a grenade model, but how would the view and controller get set up without the soldier model having to know about the view and controller of the grenade mvc?
Upvotes: 1
Views: 182
Reputation: 6159
imho, I think you taking it the wrong way..
Every game has a board or a map.
Your map "model" should be the orchestra of creations.
So if a solider is throwing a grenade:
1. your ui-controller (or solider controller) fires an event for throwing a grenade.
2. your map-model get that event and create the model for the grenade being thrown.
3. while the grenade is flying it should receive information from the map regarding obstacles passing by and etc..
Shortly put - the map is the orchestra of all visible objects on the map.
In relation to the article notice that the view is described as the "EntityRepresentation" or the map in my words.
It is NOT a nested MVC pattern as you expect to find in rich client applications.
Good Luck! :)
Upvotes: 1