simulation_MVC_Basic
Class ProjectileSprite

java.lang.Object
  extended by simulation_MVC_Basic.ShapeSprite
      extended by simulation_MVC_Basic.ProjectileSprite
All Implemented Interfaces:
Sprite

public class ProjectileSprite
extends ShapeSprite

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.

Author:
mb

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.
 void moveAlongTrajectory()
          Cause this projectile to move one step along its defined trajectory.
 
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

logger

public static java.util.logging.Logger logger
Constructor Detail

ProjectileSprite

public ProjectileSprite(java.awt.Dimension dimensionOfDrawingRegion,
                        java.awt.Point shooterTip,
                        int xDisplacement,
                        int yDisplacement)
Constructs a projectile sprite located at the specified position. The sprite will move with the specified xDisplacement and yDisplacement values.

Parameters:
dimensionOfDrawingRegion -
Method Detail

moveAlongTrajectory

public void moveAlongTrajectory()
Cause this projectile to move one step along its defined trajectory. If the trajectory travels off the screen, the projecile dies.

Overrides:
moveAlongTrajectory in class ShapeSprite

draw

public void draw(java.awt.Graphics2D g)
Description copied from class: ShapeSprite
The method draws this sprite upon the passed graphics instance.

Specified by:
draw in interface Sprite
Overrides:
draw in class ShapeSprite