game.motion
Class PieceMover

java.lang.Object
  extended by game.motion.PieceMover
All Implemented Interfaces:
Subscriber<ClockTick>

public class PieceMover
extends java.lang.Object
implements Subscriber<ClockTick>

At each tick, set the location of the Piece according to the specified Trajectory.


Constructor Summary
PieceMover(Piece p, Trajectory t)
           
 
Method Summary
 void bounce(double xfactor, double yfactor)
          Change the Trajectory associated with this piece to a new one whose velocity's x and y components are multiplied by xfactor and yfactor, respectively.
 void die()
           
 boolean isDead()
          Subscribers must be able to say when they are still alive or are dead.
 void observeEvent(ClockTick e)
          In response to a clock tick, set the location of the Relocatable to the current location of the Trajectory.
 void redirect(lab4.Vector newDirection, double speedFactor)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PieceMover

public PieceMover(Piece p,
                  Trajectory t)
Method Detail

observeEvent

public void observeEvent(ClockTick e)
In response to a clock tick, set the location of the Relocatable to the current location of the Trajectory.

Specified by:
observeEvent in interface Subscriber<ClockTick>
Parameters:
e - The PutSubEvent, varies by Publisher.

bounce

public void bounce(double xfactor,
                   double yfactor)
Change the Trajectory associated with this piece to a new one whose velocity's x and y components are multiplied by xfactor and yfactor, respectively. As one example, if xfactor=0.5 and yfactor=-1, the piece moves half as fast to the left or right, and reverses direction its up-down motion.

Parameters:
xfactor -
yfactor -

redirect

public void redirect(lab4.Vector newDirection,
                     double speedFactor)

isDead

public boolean isDead()
Description copied from interface: Subscriber
Subscribers must be able to say when they are still alive or are dead.

Specified by:
isDead in interface Subscriber<ClockTick>
Returns:
true if this Subscriber is no longer interested in receiving notifications of events from its Publisher.

die

public void die()