de.unifreiburg.twodeedoo.model
Class LinearMotionActor

java.lang.Object
  extended by de.unifreiburg.twodeedoo.model.BaseActor
      extended by de.unifreiburg.twodeedoo.model.LinearMotionActor
All Implemented Interfaces:
IActor, IKeyHandler, ISchedulable

public class LinearMotionActor
extends BaseActor
implements IActor

I move my IPuppet along a linear path.

Author:
konrad

Field Summary
 
Fields inherited from interface de.unifreiburg.twodeedoo.view.ISchedulable
NULL_OBJECT
 
Fields inherited from interface de.unifreiburg.twodeedoo.view.IKeyHandler
NULL_OBJECT
 
Constructor Summary
LinearMotionActor(IScene scene, IPuppet puppet, int x0, int y0, double vx, double vy)
          Create a new actor.
 
Method Summary
 IPuppet getPuppet()
           
 double getVelocityX()
           
 double getVelocityY()
           
 boolean run(int elapsedTimeMillis)
          Update the coordinates according to the elapsed time.
 void setPuppet(IPuppet puppet)
          Change the puppet which will be moved around.
 void setVelocity(double vx, double vy)
          Set a new velocity
 
Methods inherited from class de.unifreiburg.twodeedoo.model.BaseActor
getContainer, getScene, keyPressed, keyReleased, setContainer, setScene
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.unifreiburg.twodeedoo.model.IActor
setContainer
 
Methods inherited from interface de.unifreiburg.twodeedoo.view.IKeyHandler
keyPressed, keyReleased
 

Constructor Detail

LinearMotionActor

public LinearMotionActor(IScene scene,
                         IPuppet puppet,
                         int x0,
                         int y0,
                         double vx,
                         double vy)
Create a new actor.

Parameters:
scene - scene to put new puppets on
puppet - what to move
x0 - start coordinate in scene
y0 - start coordinate in scene
vx - x component of velocity, scene units/ms
vy - y component of velocity, scene units/ms
Method Detail

run

public boolean run(int elapsedTimeMillis)
Update the coordinates according to the elapsed time.

Specified by:
run in interface ISchedulable
Parameters:
elapsedTimeMillis - time since last call in ms
Returns:
true: this should be run again, false: finished, don't call again.

setVelocity

public void setVelocity(double vx,
                        double vy)
Set a new velocity

Parameters:
vx - in scene units per ms
vy - in scene units per ms

getVelocityX

public double getVelocityX()
Returns:
the x component of the velocity (scene units per ms)

getVelocityY

public double getVelocityY()
Returns:
the y component of the velocity (scene units per ms)

setPuppet

public void setPuppet(IPuppet puppet)
Change the puppet which will be moved around. Caller's responsibility to put it on the scene.

Parameters:
puppet - a non-null puppet.

getPuppet

public IPuppet getPuppet()
Returns:
the puppet which would be moved the next time.