As a practice project, I'm working on a turn-based battle game with a hexagonal map.
Right now I'm in an early design phase. I'm trying to figure out how to structure everything before I start thinking up functions and such.
Well, the way I'm doing this is the model (game logic) is entirely independent and is unaware of the control system that modifies it (via mouse clicks and keyboard presses), and also unaware of the view system which represents it to the user (by sound and graphics). In the end, I will slap it all together into a working game after each component is finished, and use some kind of scripting to manage gameflow and set everything up.
So, this brings up the challenge of how to organize the game while maintaining flexibility. Had I smashed it all together, I could use graphics, sound, and game logic together without much worry, but this does not work in my design. Certainly, it wouldn't be right to give the model control over sound and graphics (it doesn't even know these exist!), so an event like a rocket being fired has to be externally controlled by something that has access to both the model and view (which is divided into independant audio and visual components).
For example, let's say the player wants his unit to shoot a rocket at an enemy unit. I have to figure out how the game will handle the game logic (decreasing ammo, hit/miss, damage dealt, etc.), the graphics (such as the attack animations), and the sounds (such as the rocket firing and the resulting explosion) in an organized manner.
Here's how I see this happening, controlled by some external master, such as a script. I've labeled what I consider seperate actions on behalf of the script.
The sprite for the attacking unit is rotated to face the enemy (1 - Graphics). Now the attacker's rocket count goes down (2 - Logic). Next, a sound is played for the rocket firing (3 - Sound). Now the projectile is shown moving from the attacker to the enemy (4 - Graphics). Now, the game logic is informed of the attack and told to resolve the attack using information about the two units and the weapon involved (5 - Logic). Now, there is a branch. If there is a hit, an explosion sound is played (6A - Sound) and an explosion animation is shown (7A - Graphics). If there is a miss, the rocket can be shown simply moving past the target until it reaches its maximum range, at which point the rocket dissapears (6B - Graphics). If the enemy is destroyed in the attack, some script for the enemy exploding might be run.
Does that make any sense? And more importantly, is that a good way to go about things? Any suggestions/advice? I spent a while working on this post, so any input would be really appreciated.