javoids
Class Singularity

java.lang.Object
  extended by javoids.BasicSprite
      extended by javoids.Sprite
          extended by javoids.GravityPoint
              extended by javoids.Singularity
All Implemented Interfaces:
java.io.Serializable, Sizes

public final class Singularity
extends GravityPoint

A singularity (not quite, but close enough). This is used for white and black holes. White holes repel and sometimes create Javoids. Black holes attract and destroy anything that enters them.

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 double DEFAULT_MOVING_CHANCE
          the default chance that a singularity will move
protected static int DEFAULT_SIZE
          the sprite's default size
private  int initialSize
          the initial size of the singularity
static int MAX_NUMBER
          The maximum number of these sprites allowed in the game
protected static int MAX_SIZE
          the sprite's maximum size
protected static int MIN_SIZE
          the sprite's minimum size
private static long serialVersionUID
          This is the version used for serializing/deserializing (storing/retrieving) this object
 
Fields inherited from class javoids.GravityPoint
DEFAULT_AGING_RATE, DEFAULT_DURATION, MAX_DEATHS, MAX_DURATION, MAXIMUM_DAMAGE_CAPACITY
 
Fields inherited from class javoids.BasicSprite
size
 
Constructor Summary
Singularity(BasicSprite parent, Health health, Move move, int _size)
          Constructor
 
Method Summary
 int collide(BasicSprite sprite, BasicSprite.Collision collisionType)
           
 int collide(Explosion sprite, BasicSprite.Collision collisionType)
           
 int collide(Shield sprite, BasicSprite.Collision collisionType)
           
 int collide(ShieldedSprite sprite, BasicSprite.Collision collisionType)
           
 int collide(Singularity sprite, BasicSprite.Collision collisionType)
           
 int getDefaultSize()
           
 double getMass()
           
 int getMaximumSize()
           
 int getMinimumSize()
           
 void grow(int amount)
          Cause a singularity to change its size.
 void move()
          Move the singularity if it moves at all.
 void setGravity(BasicSprite.Gravity gravity)
          set the sprite's gravity
private  void setShape()
          Set the shape and colors of the singularity (based on the gravity type).
 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.GravityPoint
getImageNumber
 
Methods inherited from class javoids.Sprite
draw, getAreas, getColors, getMultiplier, getOriginalImage, getShape, setAreas, setColors, setColors, setImage, setShape
 
Methods inherited from class javoids.BasicSprite
accelerate, 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, setDirection, setDisplayAreas, setDuration, 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
 

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

MAX_NUMBER

public static final int MAX_NUMBER
The maximum number of these sprites allowed in the game

See Also:
Constant Field Values

DEFAULT_MOVING_CHANCE

private static final double DEFAULT_MOVING_CHANCE
the default chance that a singularity will move

See Also:
Constant Field Values

MAX_SIZE

protected static final int MAX_SIZE
the sprite's maximum size

See Also:
Constant Field Values

MIN_SIZE

protected static final int MIN_SIZE
the sprite's minimum size

See Also:
Constant Field Values

DEFAULT_SIZE

protected static final int DEFAULT_SIZE
the sprite's default size

See Also:
Constant Field Values

initialSize

private int initialSize
the initial size of the singularity

Constructor Detail

Singularity

public Singularity(BasicSprite parent,
                   Health health,
                   Move move,
                   int _size)
Constructor

Parameters:
parent - the parent of this sprite
health - the health information
move - the movment information
_size - the size this should be
Method Detail

getDefaultSize

public int getDefaultSize()
Specified by:
getDefaultSize in interface Sizes
Overrides:
getDefaultSize in class GravityPoint
Returns:
the default size of the sprite

getMaximumSize

public int getMaximumSize()
Specified by:
getMaximumSize in interface Sizes
Overrides:
getMaximumSize in class GravityPoint
Returns:
the maximum size of the sprite

getMinimumSize

public int getMinimumSize()
Specified by:
getMinimumSize in interface Sizes
Overrides:
getMinimumSize in class GravityPoint
Returns:
the minimum size fo the sprite

setSize

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

Overrides:
setSize in class GravityPoint
Parameters:
_size - the size to set for this sprite

getMass

public double getMass()
Overrides:
getMass in class GravityPoint
Returns:
the mass of the sprite (different than normal)

setGravity

public void setGravity(BasicSprite.Gravity gravity)
Description copied from class: BasicSprite
set the sprite's gravity

Overrides:
setGravity in class BasicSprite
Parameters:
gravity - the gravity type to use for the singularity

setShape

private void setShape()
Set the shape and colors of the singularity (based on the gravity type).


grow

public void grow(int amount)
Cause a singularity to change its size.

Parameters:
amount - the amount to make the singularity grow.

move

public void move()
Move the singularity if it moves at all.

Overrides:
move in class BasicSprite

collide

public int collide(Singularity sprite,
                   BasicSprite.Collision collisionType)
Parameters:
sprite - The sprite that is colliding into this sprite.
collisionType - The type of interaction required for this collision (shield on shield etc).
Returns:
the number of points obtained from the collision

collide

public int collide(BasicSprite sprite,
                   BasicSprite.Collision collisionType)
Overrides:
collide in class BasicSprite
Parameters:
sprite - The sprite that is colliding into this sprite.
collisionType - The type of interaction required for this collision (shield on shield etc).
Returns:
the number of points obtained from the collision

collide

public int collide(Explosion sprite,
                   BasicSprite.Collision collisionType)
Parameters:
sprite - The sprite that is colliding into this sprite.
collisionType - The type of interaction required for this collision (shield on shield etc).
Returns:
the number of points obtained from the collision

collide

public int collide(Shield sprite,
                   BasicSprite.Collision collisionType)
Parameters:
sprite - The sprite that is colliding into this sprite.
collisionType - The type of interaction required for this collision (shield on shield etc).
Returns:
the number of points obtained from the collision

collide

public int collide(ShieldedSprite sprite,
                   BasicSprite.Collision collisionType)
Parameters:
sprite - The sprite that is colliding into this sprite.
collisionType - The type of interaction required for this collision (shield on shield etc).
Returns:
the number of points obtained from the collision

toString

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

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