Design Document
Overall Design:
The complete game maker is divided into components and tied together using MVC design pattern. MVC is chosen for this assignment because
• View need not know how things work in the background
• Model stores the list of events, sprites and actions and is passive
• Controller lies between View and Model, which gets values from View and updates on Model, pulls values from model and displays on panel
• MVC aids in run time editing, If User is able to change configuration in run time, the values can be updated on model and game will reflect new values without any components knowing it
• The intelligence is pushed far down and all the components are loosely coupled with each other with simple interface
For communication between sprites, events and actions, following protocol is used
• Model stores the list of sprites and events and is initiated during edit time as per user request
• Action object holds sprite object to which it belongs to. If there are ten balls, associated with move action, ten action objects will be initiated with separate instances of balls associated with it
• If same ball is associated with different actions, different action object will be initiated and all action objects hold same instance of sprite
• Event and action communication is driven using observer pattern. Whenever user couples a particular event with action, that action is registered with event. When the event occurs during run time, the event updates all actions which has registered with it
Following protocol is used for collision detection
• Collision detection is considered as special type of event because the source of collision event is action.
• Hence for every action, a notification is sent back where collision detection is checked.
• If the condition for collision detection is met, appropriate actions will be taken.
• Those actions won't notify to avoid infinite loop
Following design patterns are used for sprite - events - actions
• Strategy pattern - This pattern is used in the implementation of all 3 components, sprites, events and actions.
• Observer pattern - Communication between events and actions are handled using observer pattern
• Factory pattern - Objects in sprites are initiated using factory pattern
Add Comment