|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.brackeen.javagamebook.game.Physics
The Physics class is a singleton that represents various attributes (like gravity) and the functions to manipulate objects based on those physical attributes. Currently, only gravity and scoot-up (acceleration when traveling up stairs) are supported.
Field Summary | |
static float |
DEFAULT_GRAVITY_ACCEL
Default gravity in units per millisecond squared |
static float |
DEFAULT_SCOOT_ACCEL
Default scoot-up (acceleration traveling up stairs) in units per millisecond squared. |
Method Summary | |
void |
applyGravity(GameObject object,
long elapsedTime)
Applies gravity to the specified GameObject according to the amount of time that has passed. |
float |
getGravityAccel()
Gets the gravity acceleration in units per millisecond squared. |
static Physics |
getInstance()
Gets the Physics instance. |
float |
getJumpVelocity(float jumpHeight)
Returns the vertical velocity needed to jump the specified height (based on current gravity). |
float |
getScootAccel()
Gets the scoot-up acceleration in units per millisecond squared. |
void |
jump(GameObject object,
float jumpVelocity)
Sets the specified GameObject's vertical velocity to the specified jump velocity. |
void |
jumpToHeight(GameObject object,
float jumpHeight)
Sets the specified GameObject's vertical velocity to jump to the specified height. |
void |
scootDown(GameObject object,
long elapsedTime)
Applies the negative scoot-up acceleration to the specified GameObject according to the amount of time that has passed. |
void |
scootUp(GameObject object,
long elapsedTime)
Applies the scoot-up acceleration to the specified GameObject according to the amount of time that has passed. |
void |
setGravityAccel(float gravityAccel)
Sets the gravity acceleration in units per millisecond squared. |
void |
setScootAccel(float scootAccel)
Sets the scoot-up acceleration in units per millisecond squared. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final float DEFAULT_GRAVITY_ACCEL
public static final float DEFAULT_SCOOT_ACCEL
Method Detail |
public static Physics getInstance()
public float getGravityAccel()
public void setGravityAccel(float gravityAccel)
public float getScootAccel()
public void setScootAccel(float scootAccel)
public void applyGravity(GameObject object, long elapsedTime)
public void scootUp(GameObject object, long elapsedTime)
public void scootDown(GameObject object, long elapsedTime)
public void jumpToHeight(GameObject object, float jumpHeight)
public void jump(GameObject object, float jumpVelocity)
public float getJumpVelocity(float jumpHeight)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |