gameComponents
Class ProjectileSprite

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

public class ProjectileSprite
extends java.lang.Object
implements Sprite

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.

Author:
mb

Constructor Summary
ProjectileSprite(java.awt.Dimension dimensionOfDrawingRegion, java.awt.Point initialPosition, int xDisplacement, int yDisplacement)
          Constructs a sprite located at the 0,0 position
 
Method Summary
 java.awt.geom.Rectangle2D getBounds2D()
          This method returns a rectangular box that completely encloses this sprite.
 int getCurrentX()
          Accessor for this sprite's current x position
 int getCurrentY()
          Accessor for this sprite's current y position
 void initialPosition(java.awt.Point p)
           
 void move()
           
 void setAnchor(int x, int y)
          Mutates this sprite's anchor position
 void specifyDrawing(java.awt.Graphics2D g)
          This method takes the passed Graphics2D object and specifies how this sprite should be drawn on it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProjectileSprite

public ProjectileSprite(java.awt.Dimension dimensionOfDrawingRegion,
                        java.awt.Point initialPosition,
                        int xDisplacement,
                        int yDisplacement)
Constructs a sprite located at the 0,0 position

Parameters:
dimensionOfDrawingRegion -
Method Detail

setAnchor

public void setAnchor(int x,
                      int y)
Mutates this sprite's anchor position

Parameters:
x -
y -

getCurrentX

public int getCurrentX()
Accessor for this sprite's current x position

Returns:
as specified above

getCurrentY

public int getCurrentY()
Accessor for this sprite's current y position

Returns:
as specified above

initialPosition

public void initialPosition(java.awt.Point p)

move

public void move()

specifyDrawing

public void specifyDrawing(java.awt.Graphics2D g)
This method takes the passed Graphics2D object and specifies how this sprite should be drawn on it.

Specified by:
specifyDrawing in interface Sprite

getBounds2D

public java.awt.geom.Rectangle2D getBounds2D()
This method returns a rectangular box that completely encloses this sprite. The bounding box can be assumed to be the smallest bounding box that is possible.

Specified by:
getBounds2D in interface Sprite
Returns:
as described above