Is the MVC architecture worth it?
-
- Posts: 1691
- Joined: Sun May 18, 2008 9:42 pm
Is the MVC architecture worth it?
I'm writing a game engine around Irrlicht. I read Game Coding complete and liked the architecture of their engine, but I noticed a few things that would be difficult. Animation for example: if you communicate with the game view using events, then the animation system is seperated from the game. Some things might depend on the animation system though (headshot detection for example). Is there anyone who has worked with it before, and can tell me whether it's a good idea or not?
That would be illogical captain...
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
Re: Is the MVC architecture worth it?
MVC is pretty generic...
I think MVC is only about keeping external input separate from internal engine workings and functions to allow for independant development thereof, such as with a GUI layout only passing event codes to an event manager that then triggers an appropriate function or not if there is no function yet associated with the event code.
You could make a 'headshot' event occur in game, then let it be sent to the animation event manager, then have the animation event manager call an appropriate animation function. You could also add other 'shot area' type events and so on like this.
Its pretty simple, but can often become unesseccarily complicated. So consider where you really need it.
I think MVC is only about keeping external input separate from internal engine workings and functions to allow for independant development thereof, such as with a GUI layout only passing event codes to an event manager that then triggers an appropriate function or not if there is no function yet associated with the event code.
You could make a 'headshot' event occur in game, then let it be sent to the animation event manager, then have the animation event manager call an appropriate animation function. You could also add other 'shot area' type events and so on like this.
Its pretty simple, but can often become unesseccarily complicated. So consider where you really need it.
Re: Is the MVC architecture worth it?
I think he means he can't make a headshot event without asking the animation where the head is?
Re: Is the MVC architecture worth it?
Well, he will have to ask the animation. Or have the Animation always say where its head is by sending events to manager when there is a bullet.
Get current character animation-> get current character frame->get position of pre-set marker bone for head in frame->check if bullet vector intersects.
Or: [there is a bullet] event sent: head is here in current animation frame-> bullet vector is this -> does bullet vector collide?
I usually just use whatever I need, to do to make it work, but keep simple things simple and only have complex systems need to interact via an event messenger.
Get current character animation-> get current character frame->get position of pre-set marker bone for head in frame->check if bullet vector intersects.
Or: [there is a bullet] event sent: head is here in current animation frame-> bullet vector is this -> does bullet vector collide?
I usually just use whatever I need, to do to make it work, but keep simple things simple and only have complex systems need to interact via an event messenger.