javoids
Class ShieldedSprite

java.lang.Object
  extended by javoids.BasicSprite
      extended by javoids.Sprite
          extended by javoids.ShieldedSprite
All Implemented Interfaces:
java.io.Serializable, Sizes
Direct Known Subclasses:
Bullet, Explosion, Javoid, Mine, PowerUp, Ship

public abstract class ShieldedSprite
extends Sprite

A sprite with a shield (also a sprite).

Author:
mallette
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javoids.BasicSprite
BasicSprite.Collision, BasicSprite.Gravity
 
Field Summary
private static long serialVersionUID
          This is the version used for serializing/deserializing (storing/retrieving) this object
private  Shield shield
          the ship's sheild
 
Fields inherited from class javoids.BasicSprite
size
 
Constructor Summary
protected ShieldedSprite(BasicSprite parent, Health health, Move move, Shield _shield, int _size, ImageMap.Name image, java.util.Vector<java.awt.geom.Area> areas, java.util.Vector<java.awt.Color> colors)
          Constructor
 
Method Summary
 void accelerate(double acceleration)
           
 int collide(BasicSprite sprite, BasicSprite.Collision collisionType)
           
 BasicSprite.Collision collisionDetected(ShieldedSprite shieldedSprite)
          Detect for collisions between two sprites.
 void draw(java.awt.Graphics2D g2d, java.awt.Graphics2D foregroundImage)
          Draw the shield and sprite image.
 double getMass()
           
 Shield getShield()
           
 void move()
          Move the sprite according to its velocity.
 void setDirection(double direction)
          set the sprite's direction
 void setMove(Move move)
          set the sprite's movement information
 void setRotation(double amount)
          set the sprite's rotation amount
 void setShield(Shield _shield)
           
 java.lang.String toString()
          Provide a String representation of this object.
 void turn(double turn_direction, double amount)
          turn the sprite to a new direction
 
Methods inherited from class javoids.Sprite
getAreas, getColors, getImageNumber, getMultiplier, getOriginalImage, getShape, setAreas, setColors, setColors, setImage, setShape, setSize
 
Methods inherited from class javoids.BasicSprite
age, collisionDetected, expire, explode, getAgingRate, getAreaChecking, getColor, getDamage, getDeaths, getDirection, getDuration, getGravity, getHealth, 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, setAgingRate, setAreaChecking, setAutomaticMove, setDamage, setDeaths, setDisplayAreas, setDuration, setGravity, setHealth, setHoming, setMaxDamage, setMaxDuration, setMaxLives, setMaxVelocity, setPacmanGame, setParent, setPlayer, setPoints, setScreen, setX, setY
 
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 ship's sheild

Constructor Detail

ShieldedSprite

protected ShieldedSprite(BasicSprite parent,
                         Health health,
                         Move move,
                         Shield _shield,
                         int _size,
                         ImageMap.Name image,
                         java.util.Vector<java.awt.geom.Area> areas,
                         java.util.Vector<java.awt.Color> colors)
Constructor

Parameters:
parent - the parent sprite
health - the health information
move - the movement information
_shield - the shield information
_size - the size of the sprite
image - the sprite's original image
areas - the areas that represent the sprite
colors - the colors that match the areas of the sprite
Method Detail

getShield

public Shield getShield()
Returns:
the shield of this sprite

setShield

public void setShield(Shield _shield)
Parameters:
_shield - the shield to give this sprite

setMove

public void setMove(Move move)
Description copied from class: BasicSprite
set the sprite's movement information

Overrides:
setMove in class BasicSprite
Parameters:
move - the movement information to set

setDirection

public void setDirection(double direction)
Description copied from class: BasicSprite
set the sprite's direction

Overrides:
setDirection in class BasicSprite
Parameters:
direction - the direction to set

setRotation

public void setRotation(double amount)
Description copied from class: BasicSprite
set the sprite's rotation amount

Overrides:
setRotation in class BasicSprite
Parameters:
amount - the amount to rotate every time the direction is changed

collisionDetected

public BasicSprite.Collision collisionDetected(ShieldedSprite shieldedSprite)
Detect for collisions between two sprites.

Parameters:
shieldedSprite - the other sprite
Returns:
the status of the collision (NO_COLLISION | SHIELD_SHIELD | SHIELD_SPRITE | SPRITE_SHIELD | SPRITE_SPRITE)

collide

public int collide(BasicSprite sprite,
                   BasicSprite.Collision collisionType)
Overrides:
collide in class BasicSprite
Parameters:
sprite - check for a collision with this sprite
collisionType - the collision type
Returns:
the number of points to award for the collision

draw

public void draw(java.awt.Graphics2D g2d,
                 java.awt.Graphics2D foregroundImage)
Draw the shield and sprite image.

Overrides:
draw in class Sprite
Parameters:
g2d - the graphics context to use for drawing.
foregroundImage - the image to draw on for double buffering

getMass

public double getMass()
Overrides:
getMass in class BasicSprite
Returns:
the mass of the sprite

accelerate

public void accelerate(double acceleration)
Overrides:
accelerate in class BasicSprite
Parameters:
acceleration - the amount to accelerate by at one time

turn

public void turn(double turn_direction,
                 double amount)
Description copied from class: BasicSprite
turn the sprite to a new direction

Overrides:
turn in class BasicSprite
Parameters:
turn_direction - the direction to turn
amount - the amount to turn by

move

public void move()
Move the sprite according to its velocity. Move the shield to the new location.

Overrides:
move in class BasicSprite

toString

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

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