|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavoids.Move
public class Move
A class to track the movement and speed of an game sprite.
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 |
---|
private static final long serialVersionUID
protected static final int MAX_VELOCITY
protected static final int NOTURN
protected static final int LEFT
protected static final int RIGHT
protected static final int UP
protected static final int DOWN
protected static double DEFAULT_ACCELERATE
private java.awt.Rectangle screen
private transient java.awt.geom.Point2D.Double location
private transient java.awt.geom.Point2D.Double velocity
private double maxVelocity
private double direction
Constructor Detail |
---|
public Move(Move move)
move
- the movement information to copypublic Move(java.awt.Rectangle _screen, double _x, double _y, double _direction, double _maxVelocity)
_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 moveMethod Detail |
---|
public java.awt.Rectangle getScreen()
public double getX()
public double getY()
public java.awt.geom.Point2D.Double getVelocity()
public double getMaxVelocity()
public double getDirection()
public void setScreen(java.awt.Rectangle _screen)
_screen
- the location and dimensions of the game screenpublic void setX(double _x)
_x
- the x coordinatepublic void setY(double _y)
_y
- the y coordinatepublic void setDirection(double _direction)
_direction
- the direction the sprite is facingpublic void setMaxVelocity(double _maxVelocity)
_maxVelocity
- the maximum velocity to usepublic void setMove(Move move)
move
- replace the current movement information with the new informationpublic void accelerate(double acceleration)
acceleration
- the amount to increase the sprite's velocity bypublic void turn(double turn_direction, double n)
turn_direction
- what direction the sprite should turnn
- the amount to turn bypublic void move()
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |