|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavoids.BasicSprite
public abstract class BasicSprite
Common anscestor for all game sprites
Nested Class Summary | |
---|---|
static class |
BasicSprite.Collision
Type of collision interaction |
static class |
BasicSprite.Gravity
Type of gravity interaction |
Field Summary | |
---|---|
private boolean |
automaticMove
is the sprite supposed to move automatically? |
private boolean |
displayAreas
should the areas be displayed (drawn) for this sprite |
private boolean |
exploded
was the sprite exploded (destroyed) |
private BasicSprite.Gravity |
gravity
the gravity type of the sprite |
private Health |
health
the sprite's health information |
private boolean |
homing
is the sprite a homing sprite? |
private static boolean |
isAreaChecking
should the actual object's area be used for collision detection rather than a bounding circle? |
private static boolean |
isPacmanGame
is this a special pacman game? |
private Move |
move
the movement information |
private BasicSprite |
parent
what is the parent sprite to this sprite? |
private boolean |
player
is this sprite a player? |
private int |
points
the number of points this sprite is worth when shot |
private double |
rotationAngle
theamount to rotate when turning |
private static long |
serialVersionUID
This is the version used for serializing/deserializing (storing/retrieving) this object |
protected int |
size
the sprite size |
Constructor Summary | |
---|---|
BasicSprite(BasicSprite _parent,
Health _health,
Move _move,
int _size)
|
Method Summary | ||
---|---|---|
void |
accelerate(double acceleration)
|
|
void |
age()
make the sprite age |
|
int |
collide(BasicSprite sprite,
BasicSprite.Collision collisionType)
|
|
BasicSprite.Collision |
collisionDetected(BasicSprite sprite)
|
|
abstract void |
draw(java.awt.Graphics2D g2d,
java.awt.Graphics2D foregroundImage)
|
|
void |
expire()
make the sprite expire (maximum duration reached) |
|
|
explode()
Override this method to have a larger object break up into more pieces. |
|
int |
getAgingRate()
|
|
static boolean |
getAreaChecking()
Is the game using area checking? |
|
abstract java.util.Vector<java.awt.geom.Area> |
getAreas()
|
|
java.awt.Color |
getColor()
|
|
abstract java.util.Vector<java.awt.Color> |
getColors()
|
|
int |
getDamage()
|
|
int |
getDeaths()
|
|
double |
getDirection()
|
|
int |
getDuration()
|
|
BasicSprite.Gravity |
getGravity()
|
|
Health |
getHealth()
|
|
double |
getMass()
|
|
int |
getMaxDamage()
|
|
int |
getMaxDeaths()
|
|
int |
getMaxDuration()
|
|
double |
getMaxVelocity()
|
|
Move |
getMove()
|
|
abstract double |
getMultiplier()
|
|
static boolean |
getPacmanGame()
Is the game running in pacman mode? |
|
BasicSprite |
getParent()
|
|
int |
getPoints()
|
|
double |
getRelativeVelocity(BasicSprite basicSprite)
|
|
double |
getRotation()
|
|
java.awt.Rectangle |
getScreen()
|
|
int |
getSize()
|
|
double |
getX()
|
|
double |
getY()
|
|
boolean |
isAlive()
is the sprite health |
|
boolean |
isAutomaticMove()
is the sprite moving by itself? |
|
boolean |
isDisplayAreas()
is the sprite supposed to display it's areas? |
|
boolean |
isExploded()
|
|
boolean |
isGravitySource()
is the sprite a gravity source |
|
boolean |
isGravityWell()
is the sprite a gravity well |
|
boolean |
isHoming()
is the sprite a homing sprite |
|
boolean |
isPlayer()
is the sprite a player? |
|
boolean |
isRestorable()
|
|
void |
kill()
make the sprite die |
|
int |
modifyDamage(int damage)
modify the sprite's damage level |
|
int |
modifyDeaths(int deaths)
modify the sprite's lives |
|
int |
modifyDuration(int duration)
modify the sprite's duration |
|
int |
modifyPoints(int _points)
modify the sprite's point total |
|
void |
move()
move the sprite (apply changes based on the velocity, ageing rate, and any rotation) |
|
void |
setAgingRate(int agingRate)
set the sprite's aging rate |
|
static boolean |
setAreaChecking(boolean _isAreaChecking)
Set area checking value (should the game check a sprite's actual area rather than a bounding circle) |
|
void |
setAutomaticMove(boolean _automaticMove)
set the sprite's value to say if it should move automatically |
|
void |
setDamage(int damage)
set the sprite's damage level |
|
void |
setDeaths(int lives)
set the sprite's lives |
|
void |
setDirection(double direction)
set the sprite's direction |
|
void |
setDisplayAreas(boolean _displayAreas)
set the sprite's value to say if it should display the sprite's areas when drawing an image (for debugging) |
|
void |
setDuration(int duration)
set the sprite's duration |
|
void |
setGravity(BasicSprite.Gravity _gravity)
set the sprite's gravity |
|
void |
setHealth(Health _health)
set the sprite's health information |
|
void |
setHoming(boolean _homing)
set the sprite's value to determine if it is a homing sprite or not |
|
void |
setMaxDamage(int maxDamage)
set the sprite's maximum damage level |
|
void |
setMaxDuration(int maxDuration)
set the sprite's maximum duration |
|
void |
setMaxLives(int maxLives)
set the sprite's maximum lives |
|
void |
setMaxVelocity(double maxVelocity)
set the sprite's maximum velocity |
|
void |
setMove(Move _move)
set the sprite's movement information |
|
static boolean |
setPacmanGame(boolean _isPacmanGame)
Set pacman game value |
|
void |
setParent(BasicSprite _parent)
set the sprite's parent |
|
void |
setPlayer(boolean _player)
set the sprite's value to say if it is a player or not |
|
void |
setPoints(int _points)
set the sprite's point value |
|
void |
setRotation(double _rotationAngle)
set the sprite's rotation amount |
|
void |
setScreen(java.awt.Rectangle screen)
set the sprite's screen size |
|
abstract void |
setSize(int _size)
set the sprite's size |
|
void |
setX(double x)
set the sprite's x coordinate |
|
void |
setY(double y)
set the sprite's y coordinate |
|
java.lang.String |
toString()
Provide a String representation of this object. |
|
void |
turn(double turn_direction,
double n)
turn the sprite to a new direction |
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 |
---|
private static final long serialVersionUID
private static boolean isAreaChecking
private static boolean isPacmanGame
private transient boolean exploded
private Health health
private boolean automaticMove
private boolean displayAreas
private BasicSprite.Gravity gravity
private boolean homing
private Move move
private BasicSprite parent
private boolean player
private int points
private double rotationAngle
protected int size
Constructor Detail |
---|
public BasicSprite(BasicSprite _parent, Health _health, Move _move, int _size)
_parent
- null if this is a top level sprite. pointer to this sprite's parent sprite otherwise (it's a bullet that belong to the parent)_health
- initial value of the sprite's health and life expectency_move
- initial location, direction etc._size
- initial size of spriteMethod Detail |
---|
public void accelerate(double acceleration)
acceleration
- how much to increase the velocity bypublic void kill()
public void expire()
public void age()
public boolean isExploded()
public boolean isRestorable()
public int collide(BasicSprite sprite, BasicSprite.Collision collisionType)
sprite
- The sprite that is colliding into this sprite.collisionType
- The type of interaction required for this collision (shield on shield etc).
public BasicSprite.Collision collisionDetected(BasicSprite sprite)
sprite
- did this sprite collide with another sprite?
public abstract void draw(java.awt.Graphics2D g2d, java.awt.Graphics2D foregroundImage)
g2d
- the graphics contextforegroundImage
- the buffer where drawing is performedpublic int getAgingRate()
public <E extends BasicSprite> java.util.Collection<E> explode()
E
- the type of sprite being exploded
public Health getHealth()
public static boolean getAreaChecking()
public abstract java.util.Vector<java.awt.geom.Area> getAreas()
public java.awt.Color getColor()
public abstract java.util.Vector<java.awt.Color> getColors()
public double getDirection()
public BasicSprite.Gravity getGravity()
public int getDamage()
public int getDuration()
public int getDeaths()
public double getMass()
public int getMaxDamage()
public int getMaxDuration()
public int getMaxDeaths()
public double getMaxVelocity()
public Move getMove()
public abstract double getMultiplier()
public static boolean getPacmanGame()
public BasicSprite getParent()
public int getPoints()
public double getRelativeVelocity(BasicSprite basicSprite)
basicSprite
- the other sprite that the velocity is being measured relative to
public double getRotation()
public java.awt.Rectangle getScreen()
public int getSize()
public double getX()
public double getY()
public boolean isAlive()
public boolean isAutomaticMove()
public boolean isDisplayAreas()
public boolean isGravitySource()
public boolean isGravityWell()
public boolean isHoming()
public boolean isPlayer()
public int modifyDamage(int damage)
damage
- the amount to modify the damage level by
public int modifyDuration(int duration)
duration
- the amount to modify the duration by
public int modifyDeaths(int deaths)
deaths
- the amount to modify the number of lives by
public int modifyPoints(int _points)
_points
- the number of points to modify the sprite's point value by
public void move()
public void setAgingRate(int agingRate)
agingRate
- the amount to age the sprite bypublic void setHealth(Health _health)
_health
- the new values for the sprite's health informationpublic static boolean setAreaChecking(boolean _isAreaChecking)
_isAreaChecking
- is the game using area checking for collision detection?
public void setAutomaticMove(boolean _automaticMove)
_automaticMove
- set the sprite to move automatically, if true, or disable it if false.public void setDirection(double direction)
direction
- setthe direction (0 (and 360) are up on screen, 90 is right on screen, 180 is down on screen, 270 is left on screen)public void setDisplayAreas(boolean _displayAreas)
_displayAreas
- set if the sprpublic void setGravity(BasicSprite.Gravity _gravity)
_gravity
- the type of gravity this sprite has (source, sink, none)public void setHoming(boolean _homing)
_homing
- the homing value (is it a homing sprite or not)public void setDamage(int damage)
damage
- the sprite's new damage levelpublic void setDuration(int duration)
duration
- the sprite's new durationpublic void setDeaths(int lives)
lives
- the sprite's new number of livespublic void setMaxDamage(int maxDamage)
maxDamage
- the sprite's new maximum damage levelpublic void setMaxDuration(int maxDuration)
maxDuration
- the sprite's new maximum durationpublic void setMaxLives(int maxLives)
maxLives
- the sprite's new maximum number of livespublic void setMaxVelocity(double maxVelocity)
maxVelocity
- the sprite's new maximum velocitypublic void setMove(Move _move)
_move
- the sprite's new movment informationpublic static boolean setPacmanGame(boolean _isPacmanGame)
_isPacmanGame
- is the game using pacman settings?
public void setParent(BasicSprite _parent)
_parent
- the sprite's new parentpublic void setPlayer(boolean _player)
_player
- is this sprite a player?public void setPoints(int _points)
_points
- the sprite's new point totalpublic void setRotation(double _rotationAngle)
_rotationAngle
- the sprite's new amount to rotate by when turningpublic void setScreen(java.awt.Rectangle screen)
screen
- the sprite's new screen sizepublic abstract void setSize(int _size)
_size
- the sprite's new sizepublic void setX(double x)
x
- the sprite's new x xoordinatepublic void setY(double y)
y
- the sprite's new y xoordinatepublic java.lang.String toString()
toString
in class java.lang.Object
public void turn(double turn_direction, double n)
turn_direction
- the direction to turnn
- the amount to turn by
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |