gizmoball.gameworld.gameobjects
Class Gun

java.lang.Object
  extended by gizmoball.gameworld.gameobjects.Gun
Direct Known Subclasses:
BeamGun, HomingMissileLauncher, SimpleBallGun

public abstract class Gun
extends java.lang.Object

Gun is an abstract class that represents something that will shoot out things (ie on a ship, it will shoot out balls for firing).


Field Summary
protected  GameWorldState ws
          The WorldState that things should be added to.
 
Constructor Summary
Gun(GameWorldState ws, double timeBeweenShots)
          Creates a gun.
 
Method Summary
protected abstract  void doShoot(Vect3 position, Vect3 direction)
          The method that has to be overridden, that actually shoots out the shot.
 double getRateOfFire()
           
 void setRateOfFire(double timeBetweenShots)
          Sets the amount of time that has to pass between shots.
 void shoot(Vect3 position, Vect3 direction)
          Shoots out a shot, starting at the specified position, and going in the spcifed direction (direction does not need to be a unit vector).
 void update(double dt)
          Lets this gun know that a certain amount of time has passed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ws

protected final GameWorldState ws
The WorldState that things should be added to.

Constructor Detail

Gun

public Gun(GameWorldState ws,
           double timeBeweenShots)
Creates a gun.

Parameters:
ws - the WorldState that the shots should be added to
timeBeweenShots - the time, in seconds, betwen when one shot is fired and when the next can be fired.
Method Detail

setRateOfFire

public void setRateOfFire(double timeBetweenShots)
Sets the amount of time that has to pass between shots.

Parameters:
timeBeweenShots - the time, in seconds, betwen when one shot is fired and when the next can be fired.

getRateOfFire

public double getRateOfFire()
Returns:
the time, in seconds, betwen when one shot is fired and when the next can be fired.

update

public void update(double dt)
Lets this gun know that a certain amount of time has passed.


shoot

public final void shoot(Vect3 position,
                        Vect3 direction)
Shoots out a shot, starting at the specified position, and going in the spcifed direction (direction does not need to be a unit vector). Takes rate of fire into account.

Effects:
shoots the gun in the specified direction

doShoot

protected abstract void doShoot(Vect3 position,
                                Vect3 direction)
The method that has to be overridden, that actually shoots out the shot.