COMP 310
Spring 2010

BallWar Demo

Home  Info  Owlspace  Resources

The demo should appear on your screen in its own window. To restart the demo, refresh/reload this page.

Note:  it is an Honor Code violation to attempt to decompile any supplied code


User Manual for the demo:

Because of some re-engineering to enable collisions and other features, BallWar runs slightly differently than BallWorld.

BE SURE TO SELECT BOTH AN UPDATE AND A PAINT STRATEGY BEFORE ATTEMPTING TO MAKE A BALL!

Adding Update Strategies:

  1. See the documentation for the available strategies.
  2. In the far left hand textfield, type in the name of a strategy minus the package name and without the "Strategy" part of the name (all available strategies are assumed to be named ballwar.model.strategy.XXXStrategy -- all you need to enter is the XXX.
  3. Click on Add to Lists. This will add the strategy to both the adjacent drop lists. In actuality, a factory to create the strategy is added to the drop lists.

Update strategies that can be used by themselves must be subclasses of AUpdateStrategy, which provides for random initialization of the host Ball  (note that all names are "fixed" to be "ballwar.model.strategy.XXXStrategy")

Update strategies that must be combined with at least one of the above in order to be used are subclasses of ANoOpStrategy, which provides no host initialization:   See the section below on combining update strategies (note that all names are "fixed" to be "ballwar.model.strategy.XXXStrategy"):

 

Adding Paint Strategies:

  1. See the documentation for the available strategies.
  2. In the textfield above the "Add Paint Strategy" button, type in the name of a strategy minus the package name and without the "PaintStrategy" part of the name (all available strategies are assumed to be named ballwar.model.paint.XXXPaintStrategy -- all you need to enter is the XXX.
  3. Click on Add Paint Strategy. This will add the strategy to the drop list below the button. In actuality, a factory to create the strategy is added to the drop list.  Note that not all paint strategies can be used here because they lack a no-parameter constructor.

Only paint strategies that have no-parameter constructors can be dynamically loaded and instantiated with the current BallWar system.   These paint strategies include  (the names are automatically "fixed" to be "ballwar.model.paint.XXXPaintStrategy"

 

Making and Clearing Balls:

  1. Select an update strategy from the top update strategy drop list.  
  2. Select a paint strategy from the paint strategy drop list.
  3. Clicking on the Make Selected Ball button will create a Ball with the update and paint strategies.
  4. Clicking the Clear All button will clear all the balls from the system.

Combining Update Strategies:

  1. Clicking the Combine! button will create a MultiStrategy strategy that is a composition of the strategies selected (actually, a factory that will instantiate that MultiStrategy). This strategy (factory) will be added to both drop lists. The MultiStrategy is configured such that it delegates first to the selected strategy from the top drop list then it delegates to the strategy from the bottom drop list.
  2. A ball can then be made using the combined strategy as usual.

Notes on the available update strategies:

Switcher Strategies:

  1. Clicking theMake Switcher button will make a ball with a SwitcherStrategy that defaults to a StraightStrategy behavior. All balls made use the same instance of the SwitcherStrategy.
  2. Clicking the Switch! button will cause the SwitcherStrategy's strategy to change to the selected item of the top drop list. This will affect all SwitcherStrategy balls on the screen.

Adding Players

  1. Type a player's name into the right hand text field and click the Make Player button. This will instantiate a new player and add it to the drop list below.
  2. A player is always associated with a set of movement keys. When a player is made, it is associated with the selected movement key set from the far right hand drop list. That choice, having been taken, disappears from the drop list.
  3. There are two sets of movement key sets: Arrows+End (arrow keys & End=Stop) and WASDX ( W=Up, A=Left, S=Stop, D=Right & X=Down).
  4. The MoveStrategy associates itself with the selected player when it initializes. Thus it can be controlled by the movement keys.
    1. A MoveStrategy is based on an ANoOpStrategy, so it must be combined with another strategy such as a StraightStrategy in order for the ball to be fully initialized.
    2. Click on the main ball panel area to give it focus so that the movement keys will work. The movement keys will not work if focus is on the control panel area of the frame.
  5. A limitation of the current implementation is that the player can only control the last ball made with a MoveStrategy.
  6. A player is also always has a score., which is displayed on the bottom status bar of the main window.
  7. The ScoreStrategy associates itself with the selected player when it initializes. Whenever a ball with this strategy is involved in a collision, the score is incremented.
  8. If the ball containing the ScoreStrategy is killed, the corresponding player's score is reset to zero.

 




 

© 2010 by Stephen Wong