ballwar.model.strategy
Class OneSideWallStrategy

java.lang.Object
  extended by ballwar.model.strategy.ANoOpStrategy
      extended by ballwar.model.strategy.OneSideWallStrategy
All Implemented Interfaces:
IUpdateStrategy

public class OneSideWallStrategy
extends ANoOpStrategy

Creates a wall of finite length where balls bounce of only one side. Use multiple one sided walls to create barriers of arbitrary shapes with interior and exterior bouncing surfaces.


Field Summary
private  IBallCmd bounceCmd
           
private  Ball host
           
private  IPaintStrategy paintStrategy
           
private  Point2DDouble ptA
          One end of the wall
private  Point2DDouble vecS
          Vector to the other end of the wall.
private  Color wallColor
           
 
Fields inherited from interface ballwar.model.IUpdateStrategy
NullObject
 
Constructor Summary
OneSideWallStrategy()
           
OneSideWallStrategy(Point2DDouble ptA, Point2DDouble vecS, Color wallColor)
           
 
Method Summary
private  double crossProd(Point2DDouble vec1, Point2DDouble vec2)
          scalar value of the cross product of vec1 cross vec2.
 IPaintStrategy getPaintStrategy()
           
 void init(Ball context)
          No-op
private  double innerProd(Point2DDouble vec1, Point2DDouble vec2)
          Inner product between two vectors
 void updateState(Ball context)
          No-op
 
Methods inherited from class ballwar.model.strategy.ANoOpStrategy
kill, updateCollision
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

host

private Ball host

ptA

private Point2DDouble ptA
One end of the wall


vecS

private Point2DDouble vecS
Vector to the other end of the wall. A vector V is approaching the wall from the outside if V x vecS > 0.


bounceCmd

private IBallCmd bounceCmd

wallColor

private Color wallColor

paintStrategy

private IPaintStrategy paintStrategy
Constructor Detail

OneSideWallStrategy

public OneSideWallStrategy(Point2DDouble ptA,
                           Point2DDouble vecS,
                           Color wallColor)

OneSideWallStrategy

public OneSideWallStrategy()
Method Detail

updateState

public void updateState(Ball context)
Description copied from class: ANoOpStrategy
No-op

Specified by:
updateState in interface IUpdateStrategy
Overrides:
updateState in class ANoOpStrategy
Parameters:
context - The ball to update.

init

public void init(Ball context)
Description copied from class: ANoOpStrategy
No-op

Specified by:
init in interface IUpdateStrategy
Overrides:
init in class ANoOpStrategy
Parameters:
context - The ball to initialize.

getPaintStrategy

public IPaintStrategy getPaintStrategy()

crossProd

private double crossProd(Point2DDouble vec1,
                         Point2DDouble vec2)
scalar value of the cross product of vec1 cross vec2.


innerProd

private double innerProd(Point2DDouble vec1,
                         Point2DDouble vec2)
Inner product between two vectors