|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsimulation_MVC_Basic.ShapeSprite
simulation_MVC_Basic.ProjectileSprite
public class ProjectileSprite
This class encapsulates an on-screen sprite that represents a projectile in our game. A projectile is either live or dead. Only live projectiles are shown on-screen. It has a linear trajectory that is represented by an x and y displacement per frame. The projectile has a finite lifespan, defined in terms of a number of frames. As the projectile finishes its lifespan, its sprite grows progressively smaller until it disappears.
Field Summary | |
---|---|
static java.util.logging.Logger |
logger
|
Fields inherited from class simulation_MVC_Basic.ShapeSprite |
---|
heightOfDrawingRegion, horizontalDelta, img, imgDim, MAX_DIM, verticalDelta, widthOfDrawingRegion |
Constructor Summary | |
---|---|
ProjectileSprite(java.awt.Dimension dimensionOfDrawingRegion,
java.awt.Point shooterTip,
int xDisplacement,
int yDisplacement)
Constructs a projectile sprite located at the specified position. |
Method Summary | |
---|---|
void |
draw(java.awt.Graphics2D g)
The method draws this sprite upon the passed graphics instance. |
int |
getNumberOfKills()
Returns the number of times this projectile was used to successfully hit a target |
void |
moveAlongTrajectory()
Cause this projectile to move one step along its defined trajectory. |
void |
recordKill()
Indicate that this projectile successfully hit a target |
Methods inherited from class simulation_MVC_Basic.ShapeSprite |
---|
bounceAway, explode, getAliveState, getAnchor, getBounds2D, getDimension, getNudgedRandomly, getPointsValue, isCollided, isCollided, isHit, moveToCentre, setAliveState, setAnchor, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static java.util.logging.Logger logger
Constructor Detail |
---|
public ProjectileSprite(java.awt.Dimension dimensionOfDrawingRegion, java.awt.Point shooterTip, int xDisplacement, int yDisplacement)
dimensionOfDrawingRegion
- Method Detail |
---|
public void moveAlongTrajectory()
moveAlongTrajectory
in class ShapeSprite
public void draw(java.awt.Graphics2D g)
ShapeSprite
draw
in interface Sprite
draw
in class ShapeSprite
public void recordKill()
public int getNumberOfKills()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |