|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectphysics.IMotion
physics.FrictionMotion
public class FrictionMotion
FrictionMotion.java Created: Fri Nov 12 14:55:12 2004
Imotion that mimics friction| Constructor Summary | |
|---|---|
FrictionMotion(CollisionObject colOb)
Creates a new FrictionMotion instance. |
|
| Method Summary | |
|---|---|
void |
bounce(CollisionObject col)
A bounce for this motion |
void |
calculateMomentum(CollisionObject col)
Calculates the momentum of this object using the line formulas and the angle of collision |
void |
changeMomentum(double percentoff)
Changes the momentum of the object with this motion by subtracting the momentum it must give to the object with which it collided |
boolean |
getCollided()
Return whether it has collided |
int |
getDX()
Returns dx of the velocity |
int |
getDY()
Returns dy of the velocity |
int |
getSpeed()
Returns the speed of the motion |
double |
getVelocity()
Return the velocity of the object based on dy and dx |
void |
setCoefficient(double c)
Sets the coefficient of friction |
void |
setDX(double d)
Set the dx direction |
void |
setDX(int dx)
Sets the DX direction |
void |
setDY(double d)
Set the dy direction |
void |
setDY(int dy)
Sets the DY direction |
void |
setLocation(double x,
double y)
Sets the location of the object based on a double value for x and y |
void |
setVelocity(int dx,
int dy,
int speed)
Sets the velocity of the motion based on a dx, dy, and speed |
void |
start()
Starts the MotionTimer for this motion |
void |
stillCollide(CollisionObject col)
Checks to see if the object that has this motion, and the param are still colliding, and if so moves them apart |
void |
stop()
Stops the MotionTimer for this object |
void |
switchMomentum(double m,
CollisionObject col)
Switchs the momentum of the the object with this motion and col |
void |
timerReact()
Moves the object at intervals decided by the timer and checks for collisions |
static double |
truncate(double db)
Returns a truncated double truncated after 2 decimal places |
| Methods inherited from class physics.IMotion |
|---|
setGravity |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FrictionMotion(CollisionObject colOb)
FrictionMotion instance. and set up default
values
colOb - a CollisionObject value| Method Detail |
|---|
public void setCoefficient(double c)
setCoefficient in class IMotionc - a double
public void setVelocity(int dx,
int dy,
int speed)
setVelocity in class IMotiondx - Change in xdy - Change in yspeedTimer - delaypublic void setDX(double d)
setDX in class IMotiond - -
the change in the x directionpublic void setDY(double d)
setDY in class IMotiond - the change in the y directionpublic double getVelocity()
getVelocity in class IMotionpublic int getSpeed()
getSpeed in class IMotionpublic int getDX()
getDX in class IMotionpublic int getDY()
getDY in class IMotionpublic void timerReact()
timerReact in class IMotion
public void setLocation(double x,
double y)
setLocation in class IMotionx - -
x valuey - -
y valuepublic static double truncate(double db)
db - -
the double to truncate
public void start()
start in class IMotionpublic void stop()
stop in class IMotionpublic void bounce(CollisionObject col)
bounce in class IMotioncol - a CollisionObject valuepublic void stillCollide(CollisionObject col)
col - a CollisionObject valuepublic void calculateMomentum(CollisionObject col)
col - a CollisionObject value
public void switchMomentum(double m,
CollisionObject col)
switchMomentum in class IMotionm - -
momentumcol - a CollisionObject valuepublic void changeMomentum(double percentoff)
changeMomentum in class IMotionpercentoff - a double valuepublic boolean getCollided()
getCollided in class IMotionboolean valuepublic void setDX(int dx)
setDX in class IMotionpublic void setDY(int dy)
setDY in class IMotion
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||