javoids
Class Move

java.lang.Object
  extended by javoids.Move
All Implemented Interfaces:
java.io.Serializable

public class Move
extends java.lang.Object
implements java.io.Serializable

A class to track the movement and speed of an game sprite.

Author:
mallette
See Also:
Serialized Form

Field Summary
protected static double DEFAULT_ACCELERATE
          the default acceleration rate
private  double direction
          the direction the object is moving
protected static int DOWN
          go down
protected static int LEFT
          go left
private  java.awt.geom.Point2D.Double location
          the location of the object
protected static int MAX_VELOCITY
          maximum velocity for any object in the game
private  double maxVelocity
          the maximum velocity for this object
protected static int NOTURN
          don't allow the moving object to turn
protected static int RIGHT
          go right
private  java.awt.Rectangle screen
          the screen dimensions and location
private static long serialVersionUID
          This is the version used for serializing/deserializing (storing/retrieving) this object
protected static int UP
          go up
private  java.awt.geom.Point2D.Double velocity
          the velocity of the object
 
Constructor Summary
Move(Move move)
          Constructor (copy)
Move(java.awt.Rectangle _screen, double _x, double _y, double _direction, double _maxVelocity)
          Constructor
 
Method Summary
 void accelerate(double acceleration)
           
 double getDirection()
           
 double getMaxVelocity()
           
 java.awt.Rectangle getScreen()
           
 java.awt.geom.Point2D.Double getVelocity()
           
 double getX()
           
 double getY()
           
 void move()
          move the sprite along the x and y coordinates based on the sprite's velocities
 void setDirection(double _direction)
           
 void setMaxVelocity(double _maxVelocity)
           
 void setMove(Move move)
           
 void setScreen(java.awt.Rectangle _screen)
           
 void setX(double _x)
           
 void setY(double _y)
           
 java.lang.String toString()
          Provide a String representation of this object.
 void turn(double turn_direction, double n)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
This is the version used for serializing/deserializing (storing/retrieving) this object

See Also:
Constant Field Values

MAX_VELOCITY

protected static final int MAX_VELOCITY
maximum velocity for any object in the game

See Also:
Constant Field Values

NOTURN

protected static final int NOTURN
don't allow the moving object to turn

See Also:
Constant Field Values

LEFT

protected static final int LEFT
go left

See Also:
Constant Field Values

RIGHT

protected static final int RIGHT
go right

See Also:
Constant Field Values

UP

protected static final int UP
go up

See Also:
Constant Field Values

DOWN

protected static final int DOWN
go down

See Also:
Constant Field Values

DEFAULT_ACCELERATE

protected static double DEFAULT_ACCELERATE
the default acceleration rate


screen

private java.awt.Rectangle screen
the screen dimensions and location


location

private transient java.awt.geom.Point2D.Double location
the location of the object


velocity

private transient java.awt.geom.Point2D.Double velocity
the velocity of the object


maxVelocity

private double maxVelocity
the maximum velocity for this object


direction

private double direction
the direction the object is moving

Constructor Detail

Move

public Move(Move move)
Constructor (copy)

Parameters:
move - the movement information to copy

Move

public Move(java.awt.Rectangle _screen,
            double _x,
            double _y,
            double _direction,
            double _maxVelocity)
Constructor

Parameters:
_screen - the game screen location and dimensions
_x - the x coordinate of the player
_y - the y coordinate of the player
_direction - the direction of the player (0..360 where 0 and 360 are straight up)
_maxVelocity - the maximum velocity the sprite can move
Method Detail

getScreen

public java.awt.Rectangle getScreen()
Returns:
the game screen information

getX

public double getX()
Returns:
the x coordinate

getY

public double getY()
Returns:
the y coordinate

getVelocity

public java.awt.geom.Point2D.Double getVelocity()
Returns:
the portion of the velocity along the x axis

getMaxVelocity

public double getMaxVelocity()
Returns:
the maximum velocity

getDirection

public double getDirection()
Returns:
the direction the sprite is facing

setScreen

public void setScreen(java.awt.Rectangle _screen)
Parameters:
_screen - the location and dimensions of the game screen

setX

public void setX(double _x)
Parameters:
_x - the x coordinate

setY

public void setY(double _y)
Parameters:
_y - the y coordinate

setDirection

public void setDirection(double _direction)
Parameters:
_direction - the direction the sprite is facing

setMaxVelocity

public void setMaxVelocity(double _maxVelocity)
Parameters:
_maxVelocity - the maximum velocity to use

setMove

public void setMove(Move move)
Parameters:
move - replace the current movement information with the new information

accelerate

public void accelerate(double acceleration)
Parameters:
acceleration - the amount to increase the sprite's velocity by

turn

public void turn(double turn_direction,
                 double n)
Parameters:
turn_direction - what direction the sprite should turn
n - the amount to turn by

move

public void move()
move the sprite along the x and y coordinates based on the sprite's velocities


toString

public java.lang.String toString()
Provide a String representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
String A representation of the object for debugging.