physics
Class FrictionMotion

java.lang.Object
  extended by physics.IMotion
      extended by physics.FrictionMotion

public class FrictionMotion
extends IMotion

FrictionMotion.java Created: Fri Nov 12 14:55:12 2004

Version:
An Imotion that mimics friction
Author:

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

FrictionMotion

public FrictionMotion(CollisionObject colOb)
Creates a new FrictionMotion instance. and set up default values

Parameters:
colOb - a CollisionObject value
Method Detail

setCoefficient

public void setCoefficient(double c)
Sets the coefficient of friction

Overrides:
setCoefficient in class IMotion
Parameters:
c - a double

setVelocity

public void setVelocity(int dx,
                        int dy,
                        int speed)
Sets the velocity of the motion based on a dx, dy, and speed

Specified by:
setVelocity in class IMotion
Parameters:
dx - Change in x
dy - Change in y
speedTimer - delay

setDX

public void setDX(double d)
Set the dx direction

Overrides:
setDX in class IMotion
Parameters:
d - - the change in the x direction

setDY

public void setDY(double d)
Set the dy direction

Overrides:
setDY in class IMotion
Parameters:
d - the change in the y direction

getVelocity

public double getVelocity()
Return the velocity of the object based on dy and dx

Overrides:
getVelocity in class IMotion
Returns:
velocity

getSpeed

public int getSpeed()
Returns the speed of the motion

Specified by:
getSpeed in class IMotion
Returns:
the timer delay value

getDX

public int getDX()
Returns dx of the velocity

Specified by:
getDX in class IMotion
Returns:
change in x direction

getDY

public int getDY()
Returns dy of the velocity

Specified by:
getDY in class IMotion
Returns:
change in y direction

timerReact

public void timerReact()
Moves the object at intervals decided by the timer and checks for collisions

Specified by:
timerReact in class IMotion

setLocation

public void setLocation(double x,
                        double y)
Sets the location of the object based on a double value for x and y

Overrides:
setLocation in class IMotion
Parameters:
x - - x value
y - - y value

truncate

public static double truncate(double db)
Returns a truncated double truncated after 2 decimal places

Parameters:
db - - the double to truncate
Returns:
the truncated double

start

public void start()
Starts the MotionTimer for this motion

Specified by:
start in class IMotion

stop

public void stop()
Stops the MotionTimer for this object

Specified by:
stop in class IMotion

bounce

public void bounce(CollisionObject col)
A bounce for this motion

Specified by:
bounce in class IMotion
Parameters:
col - a CollisionObject value

stillCollide

public 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

Parameters:
col - a CollisionObject value

calculateMomentum

public void calculateMomentum(CollisionObject col)
Calculates the momentum of this object using the line formulas and the angle of collision

Parameters:
col - a CollisionObject value

switchMomentum

public void switchMomentum(double m,
                           CollisionObject col)
Switchs the momentum of the the object with this motion and col

Overrides:
switchMomentum in class IMotion
Parameters:
m - - momentum
col - a CollisionObject value

changeMomentum

public 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

Overrides:
changeMomentum in class IMotion
Parameters:
percentoff - a double value

getCollided

public boolean getCollided()
Return whether it has collided

Overrides:
getCollided in class IMotion
Returns:
a boolean value

setDX

public void setDX(int dx)
Sets the DX direction

Specified by:
setDX in class IMotion

setDY

public void setDY(int dy)
Sets the DY direction

Specified by:
setDY in class IMotion