|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object physics.IMotion physics.FrictionMotion
public class FrictionMotion
FrictionMotion.java Created: Fri Nov 12 14:55:12 2004
Imotion
that mimics frictionConstructor 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 |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FrictionMotion(CollisionObject colOb)
FrictionMotion
instance. and set up default
values
colOb
- a CollisionObject
valueMethod Detail |
---|
public void setCoefficient(double c)
setCoefficient
in class IMotion
c
- a double
public void setVelocity(int dx, int dy, int speed)
setVelocity
in class IMotion
dx
- Change in xdy
- Change in yspeedTimer
- delaypublic void setDX(double d)
setDX
in class IMotion
d
- -
the change in the x directionpublic void setDY(double d)
setDY
in class IMotion
d
- the change in the y directionpublic double getVelocity()
getVelocity
in class IMotion
public int getSpeed()
getSpeed
in class IMotion
public int getDX()
getDX
in class IMotion
public int getDY()
getDY
in class IMotion
public void timerReact()
timerReact
in class IMotion
public void setLocation(double x, double y)
setLocation
in class IMotion
x
- -
x valuey
- -
y valuepublic static double truncate(double db)
db
- -
the double to truncate
public void start()
start
in class IMotion
public void stop()
stop
in class IMotion
public void bounce(CollisionObject col)
bounce
in class IMotion
col
- a CollisionObject
valuepublic void stillCollide(CollisionObject col)
col
- a CollisionObject
valuepublic void calculateMomentum(CollisionObject col)
col
- a CollisionObject
valuepublic void switchMomentum(double m, CollisionObject col)
switchMomentum
in class IMotion
m
- -
momentumcol
- a CollisionObject
valuepublic void changeMomentum(double percentoff)
changeMomentum
in class IMotion
percentoff
- a double
valuepublic boolean getCollided()
getCollided
in class IMotion
boolean
valuepublic void setDX(int dx)
setDX
in class IMotion
public void setDY(int dy)
setDY
in class IMotion
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |