tipgame.game.gammacentauri.tracker
Class BulletTracker

java.lang.Object
  extended by tipgame.game.gammacentauri.tracker.BulletTracker
All Implemented Interfaces:
Tracker

public class BulletTracker
extends java.lang.Object
implements Tracker

Tracks and moves a player's bullet.

Author:
Tom James

Field Summary
private  int height
           
private  java.awt.geom.Point2D.Double location
          The location of the bullet.
private  double offset
           
private  boolean spread
           
private  double velocity
          The velocity of the bullet.
private  double velocityX
           
private  int width
           
 
Constructor Summary
BulletTracker(double x, double y, double velocity, int width, int height)
          Constructs a bullet given an x-coordinate, y-coordinate, and velocity.
 
Method Summary
 void advanceTime(double time)
          called every time time is advanced.
 java.awt.geom.Point2D.Double getLocation()
          determines the absolute location (i.e.
 double getRotationAddition()
          determines the relative rotation.
 double getScaleFactor()
          determines the relative scaling factor.
 boolean getSpread()
           
 void setLocation(java.awt.geom.Point2D.Double point)
          Sets the location of the bullet to a given point.
 void setSpread(boolean spread)
           
 void setVelocity(double velocity)
          Sets the velocity of the bullet to a given velocity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

location

private java.awt.geom.Point2D.Double location
The location of the bullet.


velocity

private double velocity
The velocity of the bullet.


velocityX

private double velocityX

width

private int width

height

private int height

spread

private boolean spread

offset

private double offset
Constructor Detail

BulletTracker

public BulletTracker(double x,
                     double y,
                     double velocity,
                     int width,
                     int height)
Constructs a bullet given an x-coordinate, y-coordinate, and velocity.

Parameters:
x - The x-coordinate of the bullet.
y - The y-coordinate of the bullet.
velocity - The velocity of the bullet.
Method Detail

getLocation

public java.awt.geom.Point2D.Double getLocation()
Description copied from interface: Tracker
determines the absolute location (i.e. not necessarily relative to the Sprite's last location)

Specified by:
getLocation in interface Tracker
Returns:
the absolute location of the Sprite

setLocation

public void setLocation(java.awt.geom.Point2D.Double point)
Sets the location of the bullet to a given point.

Parameters:
point - The point to which the bullet will be moved.

setVelocity

public void setVelocity(double velocity)
Sets the velocity of the bullet to a given velocity.

Parameters:
velocity - The velocity to which the bullet will be set.

getScaleFactor

public double getScaleFactor()
Description copied from interface: Tracker
determines the relative scaling factor. This method will take the current size of the Sprite and scale it by the factor returned

Specified by:
getScaleFactor in interface Tracker
Returns:
the multiplicative scaling factor

getRotationAddition

public double getRotationAddition()
Description copied from interface: Tracker
determines the relative rotation. This method will take the current orientation and rotate it by the value returned.

Specified by:
getRotationAddition in interface Tracker
Returns:
the amount to rotate in radians

getSpread

public boolean getSpread()

setSpread

public void setSpread(boolean spread)

advanceTime

public void advanceTime(double time)
Description copied from interface: Tracker
called every time time is advanced. The amount of time which has passed since the last call. This method must also accept negative time intervals for reversing time. The magnitude of the negative time interval will not exceed the magnitude of the last positive time interval. Also, the keyboard and mouse inputs will remain constant when the interval is negative.

Specified by:
advanceTime in interface Tracker
Parameters:
time - the time in seconds since the last frame