gizmoball.gameworld.gameobjects
Class BallShooter

java.lang.Object
  extended by gizmoball.gameworld.GameObject
      extended by gizmoball.gameworld.Gizmo
          extended by gizmoball.gameworld.gameobjects.BallShooter
Direct Known Subclasses:
Absorber, Teleporter

public abstract class BallShooter
extends Gizmo

An abstract class that has all the functionality for collecting and shooting out balls. If the balls are hit while they're being held by the BallShooter, then it gets screwed up.

Specification Fields

Field Summary
 
Fields inherited from class gizmoball.gameworld.Gizmo
orientation, totalTranslation
 
Constructor Summary
BallShooter(Vect3 firstBallLocation, Vect3 shootTranslate, Vect3 shootSpeed)
          Sets up the critical parameters of a ball shooter.
BallShooter(Vect3 firstBallLocation, Vect3 shootTranslate, Vect3 shootSpeed, double delay, boolean countActivates, Vect3 ballPlacementDiff)
          Sets up all the parameters of a ball shooter.
 
Method Summary
 void addBall(Ball b)
          Adds a Ball to this absorber.
 void doActivate()
          Tries to shoot one ball out.
 void doUpdate(double dt)
          The same as GameObject.update().
 Vect3 getBallPlacementDiff()
           
 java.util.List<Trigger> getDefaultTriggers()
          Each BallShooter must have an AbsorbBallTrigger
 double getDelay()
           
 Vect3 getFirstBallLocation()
           
 Vect3 getShootSpeed()
           
 Vect3 getShootTranslate()
           
 void rotateAboutAxis(Vect3 center, Vect3 axis, double angle)
          Rotates this
 void translateBy(Vect3 v)
          Translates this
 
Methods inherited from class gizmoball.gameworld.Gizmo
activate, copy, getBoundingBox, getCoeffReflectionString, getColorString, getCommonAttributesString, getOrientationDoubleString, getOrientationString, getPhysicsModel, getReflectionCoeff, getTextureString, getTranslationString, getXMLDelay, getXMLDelayString, setCoefficientOfReflection, setCommonAttributes, setDelay, update
 
Methods inherited from class gizmoball.gameworld.GameObject
getGraphicsProperties, getXMLString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BallShooter

public BallShooter(Vect3 firstBallLocation,
                   Vect3 shootTranslate,
                   Vect3 shootSpeed)
Sets up the critical parameters of a ball shooter.

Parameters:
firstBallLocation - the position where the first collected ball will be
shootTranslate - when a ball is shot out, it will be translated by this much
shootSpeed - when a ball is shot out, it will have this velocity

BallShooter

public BallShooter(Vect3 firstBallLocation,
                   Vect3 shootTranslate,
                   Vect3 shootSpeed,
                   double delay,
                   boolean countActivates,
                   Vect3 ballPlacementDiff)
Sets up all the parameters of a ball shooter.

Parameters:
firstBallLocation - the position where the first collected ball will be
shootTranslate - when a ball is shot out, it will be translated by this much
shootSpeed - when a ball is shot out, it will have this velocity
delay - the delay between when one ball is shot out and the next one can be shot (in seconds)
countActivates - if a ball is supposed to be shot out at a time less than the delay after the last one, should it be shot out at the next opportunity?
ballPlacementDiff - the vector from where the first ball will be placed to where the second ball will be placed
Method Detail

doActivate

public void doActivate()
Tries to shoot one ball out. If a ball has been shot out too recently, it does not. However, it may or may not decide to record this and shoot the ball out as soon as possible.

Specified by:
doActivate in class Gizmo
Effects:
attempts to shoot out a ball

doUpdate

public void doUpdate(double dt)
Description copied from class: Gizmo
The same as GameObject.update().

Specified by:
doUpdate in class Gizmo
Effects:
takes care of propagating the delay in the gizmo and then shoots out the balls.

addBall

public void addBall(Ball b)
Adds a Ball to this absorber. Sets the velocity, position, and gravity to all be appropriate.

Requires:
b != null
Effects:
adds b to this.balls

getShootSpeed

public Vect3 getShootSpeed()
Returns:
this.shootSpeed

getFirstBallLocation

public Vect3 getFirstBallLocation()
Returns:
this.firstBallLocation

getShootTranslate

public Vect3 getShootTranslate()
Returns:
this.shootTranslate

getDelay

public double getDelay()
Returns:
this.delay

getBallPlacementDiff

public Vect3 getBallPlacementDiff()
Returns:
this.ballPlacementDiff

translateBy

public void translateBy(Vect3 v)
Description copied from class: Gizmo
Translates this

Overrides:
translateBy in class Gizmo

rotateAboutAxis

public void rotateAboutAxis(Vect3 center,
                            Vect3 axis,
                            double angle)
Description copied from class: Gizmo
Rotates this

Overrides:
rotateAboutAxis in class Gizmo

getDefaultTriggers

public java.util.List<Trigger> getDefaultTriggers()
Each BallShooter must have an AbsorbBallTrigger

Overrides:
getDefaultTriggers in class Gizmo
Returns:
a list of triggers with only an AbsorbBallTrigger