de.unifreiburg.twodeedoo.model
Class LinearMotionActor
java.lang.Object
de.unifreiburg.twodeedoo.model.BaseActor
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
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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 onpuppet
- what to movex0
- start coordinate in sceney0
- start coordinate in scenevx
- x component of velocity, scene units/msvy
- y component of velocity, scene units/ms
run
public boolean run(int elapsedTimeMillis,
IGameController controller)
- Update the coordinates according to the elapsed time.
- Specified by:
run
in interface ISchedulable
- Parameters:
elapsedTimeMillis
- time since last call in mscontroller
- to stop the game or switch activities
- 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 msvy
- 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.