org.deken.game.motion
Class CardinalMotion

java.lang.Object
  extended by org.deken.game.motion.BaseMotion
      extended by org.deken.game.motion.CardinalMotion
All Implemented Interfaces:
Motion

public class CardinalMotion
extends BaseMotion

Title: CardinalMotion

Description: This animates a game piece's Motion in the cardinal directions. North, South, East, West, North east, North west, South east & South West

Copyright: Copyright (c) 2005

Version:
1.0
Author:
Gary Deken

Field Summary
 
Fields inherited from class org.deken.game.motion.BaseMotion
boundingBox, boundingBoxSet
 
Constructor Summary
protected CardinalMotion()
          Used by copy().
  CardinalMotion(Animation[] animations)
          CardinalMotion
  CardinalMotion(Animation north_Animation, Animation east_Animation, Animation south_Animation, Animation west_Animation, Animation north_East_Animation, Animation south_East_Animation, Animation south_West_Animation, Animation north_West_Animation)
          CardinalMovement
 
Method Summary
 CardinalMotion copy()
          Copies the Motion.
 void draw(java.awt.Graphics2D graphics, int x, int y)
          This method gets the current animation and draws it.
 Animation[] getAnimations()
          Returns the Animations that make up this Motion
 float getDirection()
          Returns the direction of the Motion.
 java.awt.Image getImage()
          This returns the current frame of the current Animation.
 java.lang.String getName()
          The method returns the name of this Motion.
 void reset()
          This resets all the Animation, setting them to begin a new.
 void setDirection(float direction)
          This sets the direction in the GameVector, and sets the current Animation based on the direction.
 void setName(java.lang.String name)
          Sets the name for the Motion.
 void update(long elapseTime, float direction)
          This takes the elapse time and direction, it calls the setGameVector() and update() on the current Animation.
 
Methods inherited from class org.deken.game.motion.BaseMotion
getBounds, isBoundsSet, setBoundingBox, setBoundingBox
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CardinalMotion

public CardinalMotion(Animation north_Animation,
                      Animation east_Animation,
                      Animation south_Animation,
                      Animation west_Animation,
                      Animation north_East_Animation,
                      Animation south_East_Animation,
                      Animation south_West_Animation,
                      Animation north_West_Animation)
CardinalMovement

Parameters:
north_Animation - Animation
east_Animation - Animation
south_Animation - Animation
west_Animation - Animation
north_East_Animation - Animation
south_East_Animation - Animation
south_West_Animation - Animation
north_West_Animation - Animation

CardinalMotion

public CardinalMotion(Animation[] animations)
CardinalMotion

The animation array is set in the order of the CardinalMotion constants for directions.

private final int ANIMATION_NORTH = 0; private final int ANIMATION_NORTH_EAST = 1; private final int ANIMATION_EAST = 2; private final int ANIMATION_SOUTH_EAST = 3; private final int ANIMATION_SOUTH = 4; private final int ANIMATION_SOUTH_WEST = 5; private final int ANIMATION_WEST = 6; private final int ANIMATION_NORTH_WEST = 7;

Parameters:
animations - Animation[]

CardinalMotion

protected CardinalMotion()
Used by copy().

Method Detail

copy

public CardinalMotion copy()
Copies the Motion.

Returns:
CardinalMotion

draw

public void draw(java.awt.Graphics2D graphics,
                 int x,
                 int y)
Description copied from interface: Motion
This method gets the current animation and draws it. The animation that is retrieved from is based on the direction the game pieces is facing. When it is used with the update method, it will draw each image in the sequence as it is updated.

Parameters:
graphics -
x -
y -

getAnimations

public Animation[] getAnimations()
Description copied from interface: Motion
Returns the Animations that make up this Motion

Returns:
Animation[]

getDirection

public float getDirection()
Description copied from interface: Motion
Returns the direction of the Motion.

Returns:
float

getImage

public java.awt.Image getImage()
This returns the current frame of the current Animation.

Returns:
Image

getName

public java.lang.String getName()
Description copied from interface: Motion
The method returns the name of this Motion.

Returns:

reset

public void reset()
This resets all the Animation, setting them to begin a new.


setDirection

public void setDirection(float direction)
This sets the direction in the GameVector, and sets the current Animation based on the direction. If the direction changes the Animations are reset.

Parameters:
direction - float

setName

public void setName(java.lang.String name)
Description copied from interface: Motion
Sets the name for the Motion.


update

public void update(long elapseTime,
                   float direction)
This takes the elapse time and direction, it calls the setGameVector() and update() on the current Animation.

Parameters:
elapseTime - long
direction - double