Breakout: Design Document
Breakout is a game, made in Java using customer-designed layout managers, customer-designed containers, and Swing graphics. It consists of a breakout game, a digital clock that tells you how long the game has been played, as well as a control panel that gives you options like start/restart, pause/resume the game, undo one step, replay the whole game, save/load the game as well as switching the layout of control panel.
The Breakout project is split into several packages based on functionalities. The 'stage' package has the frame of the program, the timer class and other related customer-designed container classes. Timer notifies all the observers for every 10ms which are put in another package called panels. The 'panels' package has ClockGui,GameGui, and MenuGui. All of them are extended from a user-designed JPanelDemo class. This implements the Composite Pattern. In addition, ClockGui and GameGui share the same interface PanelObservers because they would be notified by the timer. MenuGui houses all the control buttons which are put in a packet called "buttons". For the breakout game panel, an individual package "actors" is created to house all the sprites and things that happen within the sprite. All sprites extend an abstract class, Sprite. This has all the basic information that all sprites need, such as position, size, location of the image file, and the movement algorithm used to move the sprite. All the actions that are performed by the sprites are set in the package called 'gameCommands'.
For the customer-designed layout manager, three different implementations are developed under the interface LayoutManagerDemo in the package "layout". BorderLayout, FlowoutLayout, NullLayout implement the interface. This implements the strategy and null point design patterns. All the user-designed container classes (JPanelDemo, JFrameDemo, JContentPaneDemo) are employing these user-designed layout managers by their overrided methods like setLayoutManagerDemo, updateLayoutMangerDemo, addComponentDemo, ComponentCountDemo,etc.
The "musicPlay" package has a "AePlayWave"class supporting "wav"format music playing in the game.