org.deken.game.sprites
Class Sprite

java.lang.Object
  extended by org.deken.game.sprites.Sprite
All Implemented Interfaces:
Updateable
Direct Known Subclasses:
Actor, Decor, GComponent

public abstract class Sprite
extends java.lang.Object
implements Updateable

Title: Sprite

Description: Base Sprite for all game items

Copyright: Copyright (c) 2005

Version:
1.0
Author:
Gary Deken

Field Summary
protected  BoundingBox boundingBox
           
protected  CollisionMap collisionMap
           
protected  GameLocation location
           
protected  SpriteSize size
           
 
Constructor Summary
Sprite()
          Sprite
Sprite(SpriteSize size)
          Sprite
 
Method Summary
abstract
<Sprite> Sprite
copy()
           
abstract  void draw(java.awt.Graphics2D graphics, int xOffset, int yOffset)
          Draws the sprite with the current offset.
 BoundingBox getBounds()
           
 int getDepth()
           
 int getHeight()
           
 GameLocation getLocation()
           
 java.lang.String getName()
           
 SpriteSize getSize()
           
 int getWidth()
           
 double getXLocation()
           
 double getYLocation()
           
 boolean removeFromMap()
          This is a flag to tell the GameMap, to remove this sprite from the map.
 void setBoundingBox(BoundingBox boundingBox)
           
 void setBoundingBox(int left, int top, int right, int bottom)
           
 void setCollisionMap(CollisionMap collisionMap)
          setCollisionMap
 void setLocation(GameLocation location)
           
 void setName(java.lang.String name)
           
 void setSize(SpriteSize spriteSize)
           
protected abstract  void spriteCollison(Sprite collideSprite)
          Handle the collision with another sprite.
 java.lang.String toString()
           
abstract  void update(long elapseTime)
          This method takes the elapse time, and calculates the new current frame of the animation.
 void updateLocation(double x, double y)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

size

protected SpriteSize size

location

protected GameLocation location

boundingBox

protected BoundingBox boundingBox

collisionMap

protected CollisionMap collisionMap
Constructor Detail

Sprite

public Sprite()
Sprite


Sprite

public Sprite(SpriteSize size)
Sprite

Parameters:
size - SpriteSize
Method Detail

copy

public abstract <Sprite> Sprite copy()
Type Parameters:
Sprite -
Returns:
Sprite

draw

public abstract void draw(java.awt.Graphics2D graphics,
                          int xOffset,
                          int yOffset)
Draws the sprite with the current offset.

Parameters:
graphics -
xOffset -
yOffset -

getBounds

public BoundingBox getBounds()
Returns:
Rectangle2D

getDepth

public int getDepth()
Returns:
int

getHeight

public int getHeight()
Returns:
int

getLocation

public GameLocation getLocation()
Returns:
GameLocation

getName

public java.lang.String getName()
Specified by:
getName in interface Updateable
Returns:
String

getSize

public SpriteSize getSize()
Returns:
SpriteSize

getWidth

public int getWidth()
Returns:
int

getXLocation

public double getXLocation()
Returns:
double

getYLocation

public double getYLocation()
Returns:
double

removeFromMap

public boolean removeFromMap()
This is a flag to tell the GameMap, to remove this sprite from the map. This is useful for when an item is taken or a monster destroyed.

Returns:

setBoundingBox

public void setBoundingBox(BoundingBox boundingBox)

setBoundingBox

public void setBoundingBox(int left,
                           int top,
                           int right,
                           int bottom)

setCollisionMap

public void setCollisionMap(CollisionMap collisionMap)
setCollisionMap

Parameters:
collisionMap - CollisionMap

setLocation

public void setLocation(GameLocation location)
Parameters:
location - GameLocation

setName

public void setName(java.lang.String name)
Parameters:
name -

setSize

public void setSize(SpriteSize spriteSize)
Parameters:
spriteSize - SpriteSize

toString

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

update

public abstract void update(long elapseTime)
Description copied from interface: Updateable
This method takes the elapse time, and calculates the new current frame of the animation.

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

updateLocation

public void updateLocation(double x,
                           double y)
Parameters:
x -
y -

spriteCollison

protected abstract void spriteCollison(Sprite collideSprite)
Handle the collision with another sprite.

Parameters:
collideSprite -