org.deken.game.movement
Class FourKeyToTile4Movement

java.lang.Object
  extended by org.deken.game.movement.BaseMovement
      extended by org.deken.game.movement.ToTile4Movement
          extended by org.deken.game.movement.FourKeyToTile4Movement
All Implemented Interfaces:
InputListener, KeyMovement, Movement, Updateable

public class FourKeyToTile4Movement
extends ToTile4Movement
implements KeyMovement

Title: FourKeyToTileMovement

Description: Maps four keyboard keys to the Cardinal directions (north, south, east west), and move the Actor to the next tile when pressed.

Copyright: Copyright (c) Mar 5, 2012

Version:
1.0
Author:
Gary Deken

Field Summary
protected  KeyDirectionAction[] keyDirectionActions
           
protected  int[] keyIDs
           
 
Fields inherited from class org.deken.game.movement.ToTile4Movement
currentXTile, currentYTile, mapSize, movingToTile, parent, running, speed, targetX, targetXTile, targetY, targetYTile
 
Fields inherited from class org.deken.game.movement.BaseMovement
gameVector, name
 
Constructor Summary
FourKeyToTile4Movement()
          KeyMovement
FourKeyToTile4Movement(int upKeyID, int downKeyID, int rightKeyID, int leftKeyID, MapSize mapSize, Actor parent)
          Creates a FourKeyMovement with the key IDs for the four cardinal directions, using the MapSize to determine if at tile, and Actor for current location.
 
Method Summary
 void addInputAction(InputAction inputAction)
          add an InputAction for monitoring.
protected  void checkReverseDirection()
          This method must be over-ridden if the implementing class can reverse, direction when moving between tiles.
 FourKeyToTile4Movement copy(Actor actor)
          Copies this movement
protected  GameVector.DIRECTION getDirectionEnum()
           
 int[] getInputActionIds()
          Gets the Key IDs.
 KeyDirectionAction[] getKeyDirectionActions()
          This methods returns the list of KeyDirectionActions for this KeyMovement.
protected  boolean isKeyInputConflicting()
           
 void locationUpdated()
           
protected  void markTileReached()
           
 void notifyListener(InputAction inputAction)
          This method is called when any event occurs.
 void setKeyDirectionAction(int index, int keyID, float direction)
          If the index is 0 or 3, set the KeyDirectionAction, with the given KeyID and Direction.
 void update(long elapseTime)
          This identifies which key was pressed or released.
 
Methods inherited from class org.deken.game.movement.ToTile4Movement
collideHorizontal, collideLayer, collideVertical, copyBase, getXUpdate, getYUpdate, isMovingToTile, reset, setRunning, setSpeed, setTargetTile
 
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, toString, wait, wait, wait
 
Methods inherited from interface org.deken.game.movement.KeyMovement
setSpeed
 
Methods inherited from interface org.deken.game.movement.Movement
collideHorizontal, collideLayer, collideVertical, getDirection, getGameVector, getXUpdate, getYUpdate
 
Methods inherited from interface org.deken.game.Updateable
getName
 

Field Detail

keyIDs

protected int[] keyIDs

keyDirectionActions

protected KeyDirectionAction[] keyDirectionActions
Constructor Detail

FourKeyToTile4Movement

public FourKeyToTile4Movement()
KeyMovement


FourKeyToTile4Movement

public FourKeyToTile4Movement(int upKeyID,
                              int downKeyID,
                              int rightKeyID,
                              int leftKeyID,
                              MapSize mapSize,
                              Actor parent)
Creates a FourKeyMovement with the key IDs for the four cardinal directions, using the MapSize to determine if at tile, and Actor for current location.

Parameters:
upKeyID -
downKeyID -
rightKeyID -
leftKeyID -
mapSize -
parent -
Method Detail

addInputAction

public void addInputAction(InputAction inputAction)
Description copied from interface: InputListener
add an InputAction for monitoring.

Specified by:
addInputAction in interface InputListener

copy

public FourKeyToTile4Movement copy(Actor actor)
Copies this movement

Specified by:
copy in interface Movement
Returns:
Movement

getInputActionIds

public int[] getInputActionIds()
Description copied from interface: InputListener
Gets the Key IDs. This is mainly used for wiring the object into the current GameMap Actions.

Specified by:
getInputActionIds in interface InputListener
Returns:
Array of InputActionIDs

getKeyDirectionActions

public KeyDirectionAction[] getKeyDirectionActions()
Description copied from interface: KeyMovement
This methods returns the list of KeyDirectionActions for this KeyMovement.

Specified by:
getKeyDirectionActions in interface KeyMovement
Returns:
KeyDirectionAction[]

locationUpdated

public void locationUpdated()

notifyListener

public void notifyListener(InputAction inputAction)
Description copied from interface: InputListener
This method is called when any event occurs.

Specified by:
notifyListener in interface InputListener
Parameters:
inputAction - InputAction

setKeyDirectionAction

public void setKeyDirectionAction(int index,
                                  int keyID,
                                  float direction)
If the index is 0 or 3, set the KeyDirectionAction, with the given KeyID and Direction.

Specified by:
setKeyDirectionAction in interface KeyMovement
Parameters:
index -
keyID -
direction -

update

public void update(long elapseTime)
This identifies which key was pressed or released. if the action was pressed, it set the GameVector to that direction, and the speed to this Movement's speed. If the key was released, the GameVector's speed is set to 0.0.

Specified by:
update in interface Movement
Specified by:
update in interface Updateable
Overrides:
update in class ToTile4Movement
Parameters:
elapseTime -

checkReverseDirection

protected void checkReverseDirection()
Description copied from class: ToTile4Movement
This method must be over-ridden if the implementing class can reverse, direction when moving between tiles. If reversing direction, you must call setTargetTile().

Overrides:
checkReverseDirection in class ToTile4Movement

markTileReached

protected void markTileReached()
Specified by:
markTileReached in class ToTile4Movement

getDirectionEnum

protected GameVector.DIRECTION getDirectionEnum()
Specified by:
getDirectionEnum in class ToTile4Movement

isKeyInputConflicting

protected boolean isKeyInputConflicting()