edu.gatech.cs2335.lemmings.graphics
Class AnimatedSprite

java.lang.Object
  extended byedu.gatech.cs2335.lemmings.graphics.AnimatedSprite

public final class AnimatedSprite
extends java.lang.Object

Class AnimatedSprite: This animated sprite will be used to render all things animated onto the screen. It will be created using a TileSet, and will treat the frames as follows: it will keep track of which direction the sprite is moving in. If we are moving in a certain direction, we will only use half of the frames - which half depends on where we are moving - from left to right means using the first half of the frames, and from right to left - the second half. If the sprite is not moving in any direction, all frames will be used in the animation.

 Revision History:
     v1.0 (Mar. 12, 2004) - Created the AnimatedSprite class
 

Version:
Version 1.0, Mar. 12, 2004
Author:
Vladimir Urazov
See Also:
TileSet, TileSetManager

Constructor Summary
AnimatedSprite()
          Creates a new AnimatedSprite instance.
AnimatedSprite(TileSet anim)
          Creates a new AnimatedSprite instance.
AnimatedSprite(TileSet anim, Direction dir, Looping loop)
          Creates a new AnimatedSprite instance.
 
Method Summary
 TileSet getAnimation()
          Returns the tileset associated with the sprite.
 int getCurrentFrame()
          Returns the current frame number.
 Looping getLoopingMode()
          Returns the looping mode.
 Direction getMovementDirection()
          Returns the direction in which the sprite is moving.
protected  int getNumFrames()
          Returns the number of frames in a complete loop of animation.
 boolean isInitialized()
          Returns true if the sprite is initialized with animation already, and false f it is not yet.
 int nextFrameNumber()
          Returns the next frame number and increments the counter.
 boolean renderSprite(java.awt.Graphics g, java.awt.Point coordinates)
          Renders the sprite at the specified coordinates.
 void setAnimation(TileSet v)
          Sets the new animation for the sprite.
 void setLoopingMode(Looping v)
          Sets a new looping mode.
 void setMovementDirection(Direction v)
          Sets a direction in which the sprite is moving.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnimatedSprite

public AnimatedSprite()
Creates a new AnimatedSprite instance.


AnimatedSprite

public AnimatedSprite(TileSet anim)
Creates a new AnimatedSprite instance.

Parameters:
anim - a TileSet value

AnimatedSprite

public AnimatedSprite(TileSet anim,
                      Direction dir,
                      Looping loop)
Creates a new AnimatedSprite instance.

Parameters:
anim - a TileSet value
dir - a Direction value
loop - a Looping value
Method Detail

isInitialized

public boolean isInitialized()
Returns true if the sprite is initialized with animation already, and false f it is not yet.

Returns:
a boolean value

getNumFrames

protected int getNumFrames()
Returns the number of frames in a complete loop of animation.

Returns:
an int value

getMovementDirection

public Direction getMovementDirection()
Returns the direction in which the sprite is moving.

Returns:
a Direction value

setMovementDirection

public void setMovementDirection(Direction v)
Sets a direction in which the sprite is moving. If the value passed in is NULL, an exception will be thrown.

Parameters:
v - a Direction value

getLoopingMode

public Looping getLoopingMode()
Returns the looping mode.

Returns:
a Looping value

setLoopingMode

public void setLoopingMode(Looping v)
Sets a new looping mode. If the value passed in is NULL, an exception will be thrown.

Parameters:
v - a Looping value

getAnimation

public TileSet getAnimation()
Returns the tileset associated with the sprite.

Returns:
a TileSet value

setAnimation

public void setAnimation(TileSet v)
Sets the new animation for the sprite.

Parameters:
v - a TileSet value

getCurrentFrame

public int getCurrentFrame()
Returns the current frame number.

Returns:
an int value.

nextFrameNumber

public int nextFrameNumber()
Returns the next frame number and increments the counter.

Returns:
an int value.

renderSprite

public boolean renderSprite(java.awt.Graphics g,
                            java.awt.Point coordinates)
Renders the sprite at the specified coordinates.

Parameters:
g - a Graphics value
coordinates - a Point value
Returns:
a boolean value