|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object group1.model.gameobject.GameObj
public abstract class GameObj
A generic, abstract object in the game.
Field Summary | |
---|---|
protected XYPair |
acceleration
The acceleration. |
static int |
ENEMY_TEAM
For objects that cause damage to Jeff but not to enemies. |
protected static double |
GRID_SPACE_SIZE
The standard size of a grid space in the environment this object will be placed in. |
protected int |
id
A special ID that represents this object. |
protected boolean |
isMovable
Whether or not this object actually moves. |
static int |
JEFF_TEAM
For objects that cause damage to enemies but not to Jeff. |
static int |
NO_TEAM
For objects that cause no damage, and for objects that can cause damage to any and all living objects. |
protected java.util.List<ObjRegion> |
regions
The list of regions within the object. |
protected java.awt.geom.Rectangle2D |
shape
A rectangle representing the position and size of the object. |
protected XYPair |
velocity
The velocity. |
Constructor Summary | |
---|---|
GameObj()
Default constructor. |
|
GameObj(double w,
double h,
boolean moves)
Constructor, with position defaulted to (0, 0). |
|
GameObj(double x,
double y,
double w,
double h,
boolean moves)
Constructor. |
Method Summary | |
---|---|
protected void |
addRegion(double x,
double y,
double w,
double h)
Add a region to this object. |
protected void |
addRegion(ObjRegion newRegion)
Add a region to this object. |
XYPair |
getAcceleration()
Get the acceleration. |
double |
getAccelerationX()
Get the x-component of the acceleration. |
double |
getAccelerationY()
Get the y-component of the acceleration. |
double |
getHeight()
Get the height of the object. |
int |
getID()
Get the ID. |
int |
getNumRegions()
Get the number of regions in this object. |
XYPair |
getPosition()
Get the position of the object. |
double |
getPositionX()
Get the x-cooridinate position of the object. |
double |
getPositionY()
Get the y-cooridinate position of the object. |
java.awt.geom.Rectangle2D |
getRectangle()
Directly get the rectangle representing the placement of this object. |
ObjRegion |
getRegion(int i)
Get the i'th region in this object. |
int |
getTeam()
Return the team of this object. |
XYPair |
getVelocity()
Get the velocity of the object. |
double |
getVelocityX()
Get the x-component of the velocity. |
double |
getVelocityY()
Get the y-component of the velocity. |
double |
getWidth()
Get the width of the object. |
java.util.List<ObjRegion> |
intersectRegions(java.awt.Shape shape)
Get the list of all regions that a shape intersects. |
boolean |
isMovable()
Get whether or not this object moves. |
protected void |
makeRegions()
A simple function to cover the object with 4 regions: a top, a bottom, a left side, and a right side. |
protected void |
makeSolid()
A simple function to make the obj "solid" by adding 4 regions to cover the entire object: a top, a bottom, a left side, and a right side. |
abstract XYPair |
move(Environment env)
Ask the object where it wants to move. |
void |
setAcceleration(double x,
double y)
Set the acceleration of the object. |
void |
setAcceleration(XYPair acc)
Set the acceleration of the object. |
void |
setAccelerationX(double x)
Set the x-component of the acceleration of the object. |
void |
setAccelerationY(double y)
Set the y-component of the acceleration of the object. |
void |
setID(int idNum)
Set the ID. |
void |
setPosition(double x,
double y)
Set the position of the object. |
void |
setPosition(XYPair values)
Set the position of the object. |
void |
setPositionX(double x)
Set the x-position of the object. |
void |
setPositionY(double y)
Set the y-position of the object. |
void |
setRectangle(double x,
double y,
double w,
double h)
Set the entire rectangle representing this object: position and size. |
void |
setSize(double w,
double h)
Set the size of the object. |
protected void |
setTeam(int teamValue)
Set the team value, to show which objects this one damages. |
void |
setVelocity(double x,
double y)
Set the velocity of the object. |
void |
setVelocity(XYPair vel)
Set the velocity of the object. |
void |
setVelocityX(double x)
Set the x-component of the velocity of the object. |
void |
setVelocityY(double y)
Set the y-component of the velocity of the object. |
void |
stopHorizontal()
Stop horizontal movement, say if it hits a wall. |
void |
stopVertical()
Stop vertical movement, say if it hits a floor or ceiling. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.awt.geom.Rectangle2D shape
protected XYPair velocity
protected XYPair acceleration
protected boolean isMovable
protected static final double GRID_SPACE_SIZE
protected java.util.List<ObjRegion> regions
protected int id
public static final int NO_TEAM
public static final int JEFF_TEAM
public static final int ENEMY_TEAM
Constructor Detail |
---|
public GameObj()
public GameObj(double w, double h, boolean moves)
w
- The width.h
- The height.moves
- Whether or not the object can move.public GameObj(double x, double y, double w, double h, boolean moves)
x
- The x-position.y
- The y-position.w
- The width.h
- The height.moves
- Whether or not the object can move.Method Detail |
---|
public abstract XYPair move(Environment env)
env
- The environment this object is in.
public java.util.List<ObjRegion> intersectRegions(java.awt.Shape shape)
shape
- The shape intersecting this object. (Typically, just a rectangle, but it can technically be anything.)
public ObjRegion getRegion(int i)
i
- The index of the region in the list.
public int getNumRegions()
protected void addRegion(double x, double y, double w, double h)
x
- The x-position.y
- The y-position.w
- The width.h
- The height.protected void addRegion(ObjRegion newRegion)
newRegion
- The object region.protected void setTeam(int teamValue)
teamValue
- The team value: NO_TEAM, JEFF_TEAM, or ENEMY_TEAM.protected void makeRegions()
protected void makeSolid()
public void stopHorizontal()
public void stopVertical()
public boolean isMovable()
public double getPositionX()
public double getPositionY()
public XYPair getPosition()
public double getWidth()
public double getHeight()
public java.awt.geom.Rectangle2D getRectangle()
public double getVelocityX()
public double getVelocityY()
public XYPair getVelocity()
public double getAccelerationX()
public double getAccelerationY()
public XYPair getAcceleration()
public void setID(int idNum)
idNum
- The ID.public int getID()
public void setPositionX(double x)
x
- The x-position.public void setPositionY(double y)
y
- The y-position.public void setPosition(double x, double y)
x
- The x-position.y
- The y-position.public void setPosition(XYPair values)
values
- The XY-coordinate pair.public void setSize(double w, double h)
w
- The width.h
- The height.public void setRectangle(double x, double y, double w, double h)
x
- The x-position.y
- The y-position.w
- The width.h
- The height.public void setVelocityX(double x)
x
- The x-component of the velocity.public void setVelocityY(double y)
y
- The y-component of the velocity.public void setVelocity(double x, double y)
x
- The x-component of the velocity.y
- The y-component of the velocity.public void setVelocity(XYPair vel)
vel
- The velocity, represented as a coordinate pair.public void setAccelerationX(double x)
x
- The x-component of the acceleration.public void setAccelerationY(double y)
y
- The y-component of the acceleration.public void setAcceleration(double x, double y)
x
- The x-component of the acceleration.y
- The y-component of the acceleration.public void setAcceleration(XYPair acc)
acc
- The acceleration, represented as a coordinate pair.public int getTeam()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |