| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Registered User
Join Date: Apr 2007
Posts: 27
|
A question about using the MVC pattern. As far as i understand it an application should have one view, one controller and one model. And different examples i have looked at have implemented this smoothly and easily.
But when creating games, it seems that the objects get more complex. Say for example that there are different bugs flying around on the screen and the user should try and click on some and avoid some. The view consists of the graphics of the bugs, animation, and user input listeners. How will the controller work? Should every bug have it's own controller? Or should every click be funneled into one controller class that decides what should happen? Hope somebody has an answer ![]() |
|
|
|
|
|
#2 |
|
rather be programming
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
|
You can totally have more than 1 view. That's the cool thing about MVC. And each view could have its own controller or they could share.
In your case, each bug could be a view.
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman |
|
|
|
|
|
|
|
|
#3 |
|
Registered User
Join Date: Apr 2007
Posts: 27
|
thanx
Guess everything depends on what is smoothest to work with later on. Also wouldn't having just one controller that handles everything break the idea of having encapsulated objects too? But at the same time it feels abit over the top to have one view, controller and model for everything on the screen |
|
|
|
|
|
#4 |
|
rather be programming
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
|
I don't think so. I think it is usually 1 controller per 1 type of view.
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman |
|
|
|
|
|
#5 |
|
Joeri Sebrechts
Join Date: Apr 2005
Location: Antwerp, Belgium
Posts: 1,462
|
For example, in a drawing program your menu/toolbox is a controller, all your image windows are views, and the actual data for the images are the models. Multiple views can exist for the same model (image), but in the end a single controller manages all the views / models.
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|