|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.deken.game.movement.GameVector
public class GameVector
Title: GameVector
Description: Vector for storing direction and speed.
Copyright: Copyright (c) 2002
Nested Class Summary | |
---|---|
static class |
GameVector.DIRECTION
|
Field Summary | |
---|---|
static float |
EAST
|
static float |
EAST_NORTH_EAST
|
static float |
EAST_SOUTH_EAST
|
static float |
NO_DIRECTION
|
static float |
NORTH
|
static float |
NORTH_EAST
|
static float |
NORTH_NORTH_EAST
|
static float |
NORTH_NORTH_WEST
|
static float |
NORTH_WEST
|
static float |
SOUTH
|
static float |
SOUTH_EAST
|
static float |
SOUTH_SOUTH_EAST
|
static float |
SOUTH_SOUTH_WEST
|
static float |
SOUTH_WEST
|
static float |
WEST
|
static float |
WEST_NORTH_WEST
|
static float |
WEST_SOUTH_WEST
|
Constructor Summary | |
---|---|
GameVector()
GameVector |
|
GameVector(double xMagnitude,
double yMagnitude)
|
|
GameVector(float directionXY,
double speedXY)
XY direction in degrees and speed (magnitude). |
Method Summary | |
---|---|
void |
add(double xMagnitude,
double yMagnitude)
Adds the specified (x, y) values to this GameVector. |
void |
add(GameVector vector)
Adds the specified GameVector to this GameVector. |
GameVector |
copy()
Make a copy of this GameVector |
double |
dot(GameVector vector)
vectorA.vectorB |
boolean |
equals(GameVector vector)
|
float |
getDirection()
Gets the XY direction in degrees. |
static float |
getDirection(double originX,
double originY,
double destinX,
double destinY)
Determine the direction from one point to the next point. |
static float |
getDirection(double originX,
double originY,
GameLocation point)
|
static GameVector.DIRECTION |
getDirection4Enum(double originX,
double originY,
double destinX,
double destinY)
Determine the enum DIRECTION from one point to the next point. |
static GameVector.DIRECTION |
getDirection4Enum(float direction)
Determine the enum DIRECTION from one point to the next point. |
static double |
getSpeed(double xMagnitude,
double yMagnitude,
float directionXY)
|
double |
getSpeedXY()
This returns the speedXY, number of pixels per millisecond. |
double |
getXMagnitude()
|
double |
getYMagnitude()
|
boolean |
isEastward()
Returns true if the direction is at least a little East. |
boolean |
isNorthward()
Returns true if the direction is at least a little North. |
boolean |
isSouthward()
Returns true if the direction is at least a little South. |
boolean |
isWestward()
Returns true if the direction is at least a little West. |
void |
normalize()
normalize |
void |
reverseDirection()
Changes the direction 180 degrees. |
static double |
roundOff(double value)
Round the double to "roundTo" decimal places. |
void |
scale(double scale)
|
void |
setDirection(float direction,
double speed)
Set the direction and speed. |
void |
setDirection(GameVector.DIRECTION direction,
double speed)
Set the direction and speed. |
void |
setMagnitudes(double xMagnitude,
double yMagnitude)
Sets the X and Y magnitudes and then calculates the direction and speed. |
void |
setXMagnitude(double xMagnitude)
|
void |
setYMagnitude(double yMagnitude)
|
void |
subtract(double xMagnitude,
double yMagnitude)
Subtracts the specified (x, y) values to this vector |
void |
subtract(GameVector vector)
Subtracts two vectors. |
java.lang.String |
toString()
|
void |
updateSpeed(double speed)
Set the speed, using the existing direction. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final float NO_DIRECTION
public static final float EAST
public static final float EAST_SOUTH_EAST
public static final float SOUTH_EAST
public static final float SOUTH_SOUTH_EAST
public static final float SOUTH
public static final float SOUTH_SOUTH_WEST
public static final float SOUTH_WEST
public static final float WEST_SOUTH_WEST
public static final float WEST
public static final float WEST_NORTH_WEST
public static final float NORTH_WEST
public static final float NORTH_NORTH_WEST
public static final float NORTH
public static final float NORTH_NORTH_EAST
public static final float NORTH_EAST
public static final float EAST_NORTH_EAST
Constructor Detail |
---|
public GameVector()
public GameVector(double xMagnitude, double yMagnitude)
xMagnitude
- doubleyMagnitude
- doublepublic GameVector(float directionXY, double speedXY)
directionXY
- intspeedXY
- doubleMethod Detail |
---|
public static float getDirection(double originX, double originY, GameLocation point)
originX
- originY
- point
-
public static float getDirection(double originX, double originY, double destinX, double destinY)
originX
- originY
- destinX
- destinY
-
public static GameVector.DIRECTION getDirection4Enum(double originX, double originY, double destinX, double destinY)
originX
- originY
- destinX
- destinY
-
public static GameVector.DIRECTION getDirection4Enum(float direction)
direction
- as degrees
public static double getSpeed(double xMagnitude, double yMagnitude, float directionXY)
public static double roundOff(double value)
value
-
public void add(double xMagnitude, double yMagnitude)
xMagnitude
- yMagnitude
- public void add(GameVector vector)
vector
- GameVectorpublic GameVector copy()
public double dot(GameVector vector)
vector
- GameVector
public boolean equals(GameVector vector)
vector
- GameVector
public float getDirection()
public double getSpeedXY()
public double getXMagnitude()
public double getYMagnitude()
public boolean isEastward()
public boolean isNorthward()
public boolean isSouthward()
public boolean isWestward()
public void normalize()
public void reverseDirection()
public void scale(double scale)
scale
- doublepublic void setDirection(float direction, double speed)
direction
- speed
- public void setDirection(GameVector.DIRECTION direction, double speed)
direction
- DIRECTIONspeed
- public void setMagnitudes(double xMagnitude, double yMagnitude)
xMagnitude
- yMagnitude
- public void setXMagnitude(double xMagnitude)
xMagnitude
- doublepublic void setYMagnitude(double yMagnitude)
yMagnitude
- doublepublic void subtract(double xMagnitude, double yMagnitude)
xMagnitude
- yMagnitude
- public void subtract(GameVector vector)
vector
- GameVectorpublic java.lang.String toString()
toString
in class java.lang.Object
public void updateSpeed(double speed)
speed
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |