May 2005
Intermediate to advanced
998 pages
26h
English
TourSprite
subclasses Sprite3D to specify the movement step and rotation amounts of the user's sprite. Here are the relevant methods:
private final static double MOVERATE = 0.3;
private final static double ROTATE_AMT = Math.PI / 16.0;
public TourSprite(String fnm, Obstacles obs)
{ super(fnm, obs); }
public boolean moveForward()
{ return moveBy(0.0, MOVERATE); }
public void rotClock()
{ doRotateY(-ROTATE_AMT); } // clockwise
TourSprite doesn't contain any behavior code to specify when the move and rotation methods should be called and is placed in a separate Behavior class (TouristControls for TourSprite). Behavior classes are explained after the next section.