PACKAGE STRUCTURE:
Main module:
This package contains the main frame of the game in which there is custom panel (drag and drop panel), Game panel (where the game is played and time is shown) and Edit panel (where each sprite properties are set). When the frame object is generated, all the three panels are also generated and added to the frame. The game starts from MainFrame.java class.
Stagepanel:
This package consists of all the view components which the three panels mentioned above . GamePanel consists of two panels StagePanel and TimerPanel where StagePanel is where the game is actually played and TimerPanel has the Timer for the game. These panels are placed using JTabbedPane which allows the user to change the properties of the game as well as specify the winning and losing condition. The user can select the properties set the speed using the slider. SpringUtilities class is used for providing Spring Layout and the code is taken from sun Microsystems Spring Layout specification. TransferableImage class is used for the Drag and Drop functionality to drag from the custom panel to the stagepanel.
GamePanel.java:
This class has the drop function for the Drag and Drop functionality of the UI. It also has an internal drag function for repositioning the already dragged image. We have used a popup menu which is shown on the right click on any sprite. On the selection of copy menuitem, the sprite is cloned which means the properties are also cloned. It extends DropTargetAdapter for drop functionality and implements ActionListener, MouseListener, DragGestureListener for internal Drag and Drop and Observer so that if the user changes the size of the image then in the update method the size is changed. Observer pattern is used to provide this dynamicity.
EditPanel.java:
This is the main properties class for sprites. Here along with sprite properties the game properties are also set. This has SpringLayout for arrangement of components. This class calls the controller (GameController.java) to set the properties of sprite. In turn the controller calls the model (Actor.java) to set the properties per actor (sprite). It also contains the winning and losing conditions for the game and Time in Seconds if the user wants to time himself. We have used JProgressBar component as a timer. It is filled on every 10 milliseconds if the timer is running. The progress bar uses the game timer. The game timer is in the controller.
Controller:
This package consists of the controller for the game which is GameController.java. It consists of the object of the view and the model and the timer for the game. When an actor is to be added or removed the addActorAt and removeActorAt methods are called respectively. One of the main things in the code is that actors are stored in an Arraylist called clonelist which is added to actor list. The logic is all the clones of the actor are in clonelist and the clonelist is added to actorlist.
Actor.java:
This is the model and holds all the properties that are set for the sprite. Here the events and actions are added and mapped for the sprite. Also for a particular event type which is an enum , the event is executed here.
Actions:
This package consists of all the action classes that is if a new action is to be added a new class is to be created which is just to be called when the action is to be performed from the ExecuteAction class.
EventObervable:
This package consists of all the event classes and like for the actions each event is a class and a particular event class is called from the ExecuteEvent class whenever it has to be executed.
Commands:
We have a special functionality called Auto whose class is defined here. Also collision action is defined here. 