org.deken.game.movement
Class Wander8Movement

java.lang.Object
  extended by org.deken.game.movement.BaseMovement
      extended by org.deken.game.movement.Wander8Movement
All Implemented Interfaces:
Movement, Updateable

public class Wander8Movement
extends BaseMovement
implements Movement

Title: Wander8Movement

Description: This is a random movement that moves only in 8 directions.

Copyright: Copyright (c) Dec 18, 2010

Version:
1.0
Author:
Gary Deken

Nested Class Summary
 class Wander8Movement.ExtremeRandomness
          The randomness is Extreme, in that it will change a random direction often.
 class Wander8Movement.MildRandomness
          The randomness is mild, in that it is most likely to go straight.
 class Wander8Movement.Randomness
          class to determine the randomness of the wandering.
 
Field Summary
 
Fields inherited from class org.deken.game.movement.BaseMovement
gameVector, name
 
Constructor Summary
Wander8Movement()
           
Wander8Movement(double speed, int minDistance)
          Create a Wander8Movement with a speed and a minDistance.
Wander8Movement(double speed, int minDistance, float direction)
          Create a Wander8Movement with a speed and a minDistance.
Wander8Movement(double speed, int minDistance, float direction, Wander8Movement.Randomness randomness)
          Create a Wander8Movement with a speed and a minDistance.
Wander8Movement(double speed, int minDistance, Wander8Movement.Randomness randomness)
          Create a Wander8Movement with a speed and a minDistance.
 
Method Summary
 void collideHorizontal()
          Handle a horizontal collision.
 void collideLayer()
          Adjust the layer (z axis) movement to a collision.
 void collideVertical()
          Handle a vertical
 Wander8Movement copy(Actor actor)
          Copies the movement.
 double getCurrentDistance()
           
 int getMinDistance()
           
 double getSpeed()
           
 double getXUpdate()
          This returns the amount of X movement for a given update.
 double getYUpdate()
          This returns the amount of Y movement for a given update.
 void setRunning(boolean running)
           
 void setSpeed(double speed)
           
 java.lang.String toString()
           
 void update(long elapseTime)
          This method takes the elapse time, since the last update, and to determine the next movement to set to the GameVector.
 
Methods inherited from class org.deken.game.movement.BaseMovement
baseCopy, getDirection, getGameVector, getName, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.deken.game.movement.Movement
getDirection, getGameVector
 
Methods inherited from interface org.deken.game.Updateable
getName
 

Constructor Detail

Wander8Movement

public Wander8Movement()

Wander8Movement

public Wander8Movement(double speed,
                       int minDistance)
Create a Wander8Movement with a speed and a minDistance. The minDistance is used for how long the Actor will move before changing direction. It will start with a random direction and have a default Randomness of MildRandomness.

Parameters:
speed -
minDistance -

Wander8Movement

public Wander8Movement(double speed,
                       int minDistance,
                       Wander8Movement.Randomness randomness)
Create a Wander8Movement with a speed and a minDistance. The minDistance is used for how long the Actor will move before changing direction. It will start with a random direction and set the Randomness.

Parameters:
speed -
minDistance -
randomness -

Wander8Movement

public Wander8Movement(double speed,
                       int minDistance,
                       float direction)
Create a Wander8Movement with a speed and a minDistance. The minDistance is used for how long the Actor will move before changing direction. It will start with the set direction and have a default Randomness of MildRandomness.

Parameters:
speed -
minDistance -
direction -

Wander8Movement

public Wander8Movement(double speed,
                       int minDistance,
                       float direction,
                       Wander8Movement.Randomness randomness)
Create a Wander8Movement with a speed and a minDistance. The minDistance is used for how long the Actor will move before changing direction. It will start with the set direction and set the randomness.

Parameters:
speed -
minDistance -
direction -
randomness -
Method Detail

collideHorizontal

public void collideHorizontal()
Handle a horizontal collision.

Specified by:
collideHorizontal in interface Movement

collideVertical

public void collideVertical()
Handle a vertical

Specified by:
collideVertical in interface Movement

collideLayer

public void collideLayer()
Description copied from interface: Movement
Adjust the layer (z axis) movement to a collision.

Specified by:
collideLayer in interface Movement

copy

public Wander8Movement copy(Actor actor)
Copies the movement.

Specified by:
copy in interface Movement
Returns:
Wander8Movement

getCurrentDistance

public double getCurrentDistance()

getMinDistance

public int getMinDistance()

getSpeed

public double getSpeed()

getXUpdate

public double getXUpdate()
Description copied from interface: Movement
This returns the amount of X movement for a given update.

Specified by:
getXUpdate in interface Movement
Returns:
double xUpdate

getYUpdate

public double getYUpdate()
Description copied from interface: Movement
This returns the amount of Y movement for a given update.

Specified by:
getYUpdate in interface Movement
Returns:
double yUpdate

setRunning

public void setRunning(boolean running)

setSpeed

public void setSpeed(double speed)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

update

public void update(long elapseTime)
Description copied from interface: Movement
This method takes the elapse time, since the last update, and to determine the next movement to set to the GameVector.

Specified by:
update in interface Movement
Specified by:
update in interface Updateable
Parameters:
elapseTime -