|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectgroup1.model.Environment
public class Environment
An environment, or a level, that contains a list of game objects. (Terrain, enemies, Jeff, etc.) In other words, the various areas in which the action will take place.
Note that this class and the GameObj classes technically store the data upside-down. Java treats the y-axis as top-to-bottom, which is too confusing for actual physics calculations. So, we make all calculations as though it's represented from bottom-to-top, then reverse the values later.
| Constructor Summary | |
|---|---|
Environment()
Default constructor. |
|
Environment(java.util.List<GameObj> objs,
Jeff jef,
int w,
int h)
Constructor. |
|
| Method Summary | |
|---|---|
void |
addObject(GameObj obj)
Add an object. |
void |
addObject(GameObj obj,
double x,
double y)
Add object, with the position explicitly defined by the caller. |
void |
addObject(GameObj obj,
GameObj creatorObj)
Add an object, with the position defined as being the position of the object that "created" or "threw" it. |
double |
getGravity()
Get the gravity from the environment. |
XYPair |
getGroundVelocity(GameObj obj)
Check whether or not an object is on ground that it can walk on, AND return the velocity of the ground if it's on ground. |
double |
getHeight()
Return the "true" height of the Environment. |
XYPair |
getJeffsPosition()
Get Jeff's position. |
GameObj |
getObject(int i)
Return the specified object in the environment. |
java.util.List<GameObj> |
getObjectList()
Return the full list of objects in the Environment. |
java.util.List<GameObj> |
getObjectListCopy()
Return a copy of the list of objects in the Environment.\ |
int |
getObjectListSize()
Return the size of the list of all objects in the environment. |
double |
getWidth()
Return the "true" width of the Environment. |
boolean |
isObjectNearLadder(GameObj obj)
Check whether or not an object is close enough to a ladder to grab it. |
boolean |
isObjectOnGround(GameObj obj)
Check whether or not an object is on ground that it can walk on. |
boolean |
removeObj(GameObj obj)
Remove an object. |
void |
setGravity(double grav)
Set the gravity. |
TimeClickReturn |
timeClick()
Calculates and sets the positions and velocities of all objects in the environment, based upon the objects' own movements and hit detection. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Environment()
public Environment(java.util.List<GameObj> objs,
Jeff jef,
int w,
int h)
objs - The list of GameObjs to initialize this environment with.jef - The hero of the game. (The only object that carries over between environments.)w - The width of the environment.h - The height of the environment.| Method Detail |
|---|
public void setGravity(double grav)
grav - The gravity value. (Should be negative. Unless we're falling up or something...?)public TimeClickReturn timeClick()
This should be called by the Game class at each time click.
public XYPair getGroundVelocity(GameObj obj)
obj - The object in question.
public boolean isObjectOnGround(GameObj obj)
obj - The object in question.
public boolean isObjectNearLadder(GameObj obj)
obj - The object in question.
public double getGravity()
public XYPair getJeffsPosition()
public java.util.List<GameObj> getObjectList()
public java.util.List<GameObj> getObjectListCopy()
public GameObj getObject(int i)
i - The index of the GameObj.
public int getObjectListSize()
public double getHeight()
public double getWidth()
public void addObject(GameObj obj,
GameObj creatorObj)
obj - The GameObj being added.creatorObj - The object "creating" or "throwing" this object.
public void addObject(GameObj obj,
double x,
double y)
obj - The GameObj being added.x - The x-position of the object.y - The x-position of the object.public void addObject(GameObj obj)
obj - The GameObj being added.public boolean removeObj(GameObj obj)
obj - The GameObj being removed.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||