tipgame.game.gammacentauri.tracker
Class ShipTracker

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

public class ShipTracker
extends java.lang.Object
implements Tracker

Tracks and moves a player's ship.

Author:
Tom James

Field Summary
static double ACCEL_DAMPENER
          The amount by which the velocity of the ship will be divided each time frame.
private  int height
           
private  java.awt.geom.Point2D.Double location
          The location of the ship.
private  double velocity
          The velocity of the ship.
private  int width
           
 
Constructor Summary
ShipTracker(double x, double y, double velocity, int width, int height)
          Constructs a ship 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.
 double getVelocity()
           
 void setLocation(double x, double y)
           
 void setVelocity(double velocity)
          Sets the velocity of the ship 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 ship.


velocity

private double velocity
The velocity of the ship.


ACCEL_DAMPENER

public static final double ACCEL_DAMPENER
The amount by which the velocity of the ship will be divided each time frame.

See Also:
Constant Field Values

width

private int width

height

private int height
Constructor Detail

ShipTracker

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

Parameters:
x - The x-coordinate of the ship.
y - The y-coordinate of the ship.
velocity - The velocity of the ship.
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

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

setVelocity

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

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

getVelocity

public double getVelocity()

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

setLocation

public void setLocation(double x,
                        double y)