org.deken.game.motion
Interface Motion

All Known Implementing Classes:
BaseMotion, CardinalMotion, FourWayMotion, SingleMotion, StaticMotion, TwoWayMotion

public interface Motion

Title: Motion

Description: This interface give motion to a game piece. These classes will maintain the Animation objects that the motion uses, updating the correct one and return the current image to be displayed. There will be an Animation for each direction that the Game Piece will need motion for.

Copyright: Copyright (c) 2005

Version:
1.0
Author:
Gary Deken

Method Summary
 Motion 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
 BoundingBox getBounds()
          Returns the motions BoundingBox for collision detection at the Motion level.
 float getDirection()
          Returns the direction of the Motion.
 java.awt.Image getImage()
          This method returns the current frame of the animation.
 java.lang.String getName()
          The method returns the name of this Motion.
 boolean isBoundsSet()
          Returns true if the BoundingBox is set for Collision.
 void reset()
          This resets the animation strip back to its default (or initial start) frame, based on the direction the game piece is going.
 void setBoundingBox(BoundingBox boundingBox)
          Set the BoundingBox size for Collision detection at the Motion level.
 void setBoundingBox(int left, int top, int right, int bottom)
          Set the BoundingBox size for Collision detection at the Motion level.
 void setDirection(float direction)
          This is for setting the direction.
 void setName(java.lang.String name)
          Sets the name for the Motion.
 void update(long elapseTime, float direction)
          This method takes the elapse time and the the direction and updates the Animation used based on the direction.
 

Method Detail

copy

Motion copy()
Copies the motion.

Returns:
Motion

draw

void draw(java.awt.Graphics2D graphics,
          int x,
          int y)
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

Animation[] getAnimations()
Returns the Animations that make up this Motion

Returns:
Animation[]

getBounds

BoundingBox getBounds()
Returns the motions BoundingBox for collision detection at the Motion level.

Returns:
BoundingBox

getDirection

float getDirection()
Returns the direction of the Motion.

Returns:
float

getImage

java.awt.Image getImage()
This method returns the current frame of the animation. 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 return each image in the sequence as it is updated.

Returns:
Image

getName

java.lang.String getName()
The method returns the name of this Motion.

Returns:

isBoundsSet

boolean isBoundsSet()
Returns true if the BoundingBox is set for Collision.

Returns:
boolean

reset

void reset()
This resets the animation strip back to its default (or initial start) frame, based on the direction the game piece is going. This is useful for starting a game piece back to the beginning after it stopped or was going a different direction.


setBoundingBox

void setBoundingBox(BoundingBox boundingBox)
Set the BoundingBox size for Collision detection at the Motion level.

Parameters:
boundingBox -

setBoundingBox

void setBoundingBox(int left,
                    int top,
                    int right,
                    int bottom)
Set the BoundingBox size for Collision detection at the Motion level.

Parameters:
left -
top -
right -
bottom -

setDirection

void setDirection(float direction)
This is for setting the direction.

Parameters:
direction - int

setName

void setName(java.lang.String name)
Sets the name for the Motion.

Parameters:
name -

update

void update(long elapseTime,
            float direction)
This method takes the elapse time and the the direction and updates the Animation used based on the direction.

Parameters:
elapseTime - long
direction -