javoids
Class Sprite

java.lang.Object
  extended by javoids.BasicSprite
      extended by javoids.Sprite
All Implemented Interfaces:
java.io.Serializable, Sizes
Direct Known Subclasses:
GravityPoint, Shield, ShieldedSprite

public abstract class Sprite
extends BasicSprite

A sprite class to have a moving game object.

Author:
mallette
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javoids.BasicSprite
BasicSprite.Collision, BasicSprite.Gravity
 
Field Summary
private  java.util.Vector<java.awt.geom.Area> areas
          the areas representing this sprite's shape
private  java.util.Vector<java.awt.Color> colors
          the colors that correspond to a sprite's areas
private  ImageMap.Name imageNumber
          the image name representing the sprite
private  double initialX
          the initial x coordinate
private  double initialY
          the initial y coordinate
private  ImageMap.Name originalImageNumber
          the original image name
private static long serialVersionUID
          This is the version used for serializing/deserializing (storing/retrieving) this object
private  Shapes.Shape shape
          the sprite's shape
private  Shield shield
          the shield protecting the sprite
 
Fields inherited from class javoids.BasicSprite
size
 
Constructor Summary
Sprite(BasicSprite parent, Health health, Move move, int _size, ImageMap.Name _imageNumber, java.util.Vector<java.awt.geom.Area> _areas, java.util.Vector<java.awt.Color> _colors)
          Constructor
 
Method Summary
 void draw(java.awt.Graphics2D g2d, java.awt.Graphics2D foregroundImage)
          Draw the shapes or images onto the foreground image (for double buffering).
private  void drawImage(java.awt.Graphics2D g2d, java.awt.Graphics2D foregroundImage)
          Draw an image on the screen.
private  void drawShape(java.awt.Graphics2D g2d, java.awt.Graphics2D foregroundImage, java.awt.geom.Area area)
          Draw a single area on the screen.
private  void drawShapes(java.awt.Graphics2D g2d, java.awt.Graphics2D foregroundImage)
          Draw all of a sprite's shapes on the screen
 java.util.Vector<java.awt.geom.Area> getAreas()
           
 java.util.Vector<java.awt.Color> getColors()
           
abstract  ImageMap.Name getImageNumber()
           
 double getMultiplier()
           
 ImageMap.Name getOriginalImage()
           
 Shapes.Shape getShape()
           
private  void setAreas()
          Set the areas that represent the sprite's shape.
 void setAreas(java.util.Vector<java.awt.geom.Area> _areas)
           
protected  void setColors()
          Set the colors that go with the sprit'es areas.
 void setColors(java.util.Vector<java.awt.Color> _colors)
           
 void setImage(ImageMap.Name _imageNumber)
           
 void setShape(Shapes.Shape _shape)
           
 void setSize(int _size)
          set the sprite's size
 java.lang.String toString()
          Provide a String representation of this object.
 
Methods inherited from class javoids.BasicSprite
accelerate, age, collide, collisionDetected, expire, explode, getAgingRate, getAreaChecking, getColor, getDamage, getDeaths, getDirection, getDuration, getGravity, getHealth, getMass, getMaxDamage, getMaxDeaths, getMaxDuration, getMaxVelocity, getMove, getPacmanGame, getParent, getPoints, getRelativeVelocity, getRotation, getScreen, getSize, getX, getY, isAlive, isAutomaticMove, isDisplayAreas, isExploded, isGravitySource, isGravityWell, isHoming, isPlayer, isRestorable, kill, modifyDamage, modifyDeaths, modifyDuration, modifyPoints, move, setAgingRate, setAreaChecking, setAutomaticMove, setDamage, setDeaths, setDirection, setDisplayAreas, setDuration, setGravity, setHealth, setHoming, setMaxDamage, setMaxDuration, setMaxLives, setMaxVelocity, setMove, setPacmanGame, setParent, setPlayer, setPoints, setRotation, setScreen, setX, setY, turn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javoids.Sizes
getDefaultSize, getMaximumSize, getMinimumSize
 

Field Detail

serialVersionUID

private static final long serialVersionUID
This is the version used for serializing/deserializing (storing/retrieving) this object

See Also:
Constant Field Values

shield

private Shield shield
the shield protecting the sprite


imageNumber

private ImageMap.Name imageNumber
the image name representing the sprite


originalImageNumber

private ImageMap.Name originalImageNumber
the original image name


shape

private Shapes.Shape shape
the sprite's shape


initialX

private double initialX
the initial x coordinate


initialY

private double initialY
the initial y coordinate


areas

private java.util.Vector<java.awt.geom.Area> areas
the areas representing this sprite's shape


colors

private java.util.Vector<java.awt.Color> colors
the colors that correspond to a sprite's areas

Constructor Detail

Sprite

public Sprite(BasicSprite parent,
              Health health,
              Move move,
              int _size,
              ImageMap.Name _imageNumber,
              java.util.Vector<java.awt.geom.Area> _areas,
              java.util.Vector<java.awt.Color> _colors)
Constructor

Parameters:
parent - the parent of this sprite
health - the health information
move - the movment information
_size - the size this should be
_imageNumber - the image numbeer to use for this sprite
_areas - the areas used to represent or draw the sprite (needed even if using an image for area collision detection)
_colors - the colors of each area (in the same order as the areas)
Method Detail

getColors

public java.util.Vector<java.awt.Color> getColors()
Specified by:
getColors in class BasicSprite
Returns:
the colors associate with this sprite

getShape

public Shapes.Shape getShape()
Returns:
get the shape name for this sprite

setShape

public void setShape(Shapes.Shape _shape)
Parameters:
_shape - set the shape name for this sprite

getAreas

public java.util.Vector<java.awt.geom.Area> getAreas()
Specified by:
getAreas in class BasicSprite
Returns:
the areas associated with this sprite

setAreas

public void setAreas(java.util.Vector<java.awt.geom.Area> _areas)
Parameters:
_areas - the areas that represent the shape of this sprite

setAreas

private void setAreas()
Set the areas that represent the sprite's shape.


setColors

public void setColors(java.util.Vector<java.awt.Color> _colors)
Parameters:
_colors - the colors that correspond to the areas of this sprite

setColors

protected void setColors()
Set the colors that go with the sprit'es areas.


setSize

public void setSize(int _size)
Description copied from class: BasicSprite
set the sprite's size

Specified by:
setSize in class BasicSprite
Parameters:
_size - the size of the sprite

draw

public void draw(java.awt.Graphics2D g2d,
                 java.awt.Graphics2D foregroundImage)
Draw the shapes or images onto the foreground image (for double buffering). Draw parts of the sprite in different locations for when parts wrap around a screen border.

Specified by:
draw in class BasicSprite
Parameters:
g2d - the graphics context used to draw this sprite
foregroundImage - the image use to draw this sprite on

drawImage

private void drawImage(java.awt.Graphics2D g2d,
                       java.awt.Graphics2D foregroundImage)
Draw an image on the screen.

Parameters:
g2d - the graphics context used to draw this sprite
foregroundImage - the image use to draw this sprite on

drawShape

private void drawShape(java.awt.Graphics2D g2d,
                       java.awt.Graphics2D foregroundImage,
                       java.awt.geom.Area area)
Draw a single area on the screen.

Parameters:
g2d - the graphics context used to draw this sprite
foregroundImage - the image use to draw this sprite on
area - the are to draw

drawShapes

private void drawShapes(java.awt.Graphics2D g2d,
                        java.awt.Graphics2D foregroundImage)
Draw all of a sprite's shapes on the screen

Parameters:
g2d - the graphics context used to draw this sprite
foregroundImage - the image use to draw this sprite on

getImageNumber

public abstract ImageMap.Name getImageNumber()
Returns:
the image name for this sprite's image

getOriginalImage

public ImageMap.Name getOriginalImage()
Returns:
the original image name for this sprite's image

getMultiplier

public double getMultiplier()
Specified by:
getMultiplier in class BasicSprite
Returns:
the scaling factor for this sprite's image/shapes

setImage

public void setImage(ImageMap.Name _imageNumber)
Parameters:
_imageNumber - set the image name for this sprite

toString

public java.lang.String toString()
Provide a String representation of this object.

Overrides:
toString in class BasicSprite
Returns:
String A representation of the object for debugging.