gameComponents
Class ShooterSprite

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

public class ShooterSprite
extends java.lang.Object
implements Sprite

This class encapsulates an on-screen sprite that represents a shooter in our asteroids-like video game. This class supports linear translation of the sprite along the x and y dimensions. It does not support rotation yet.

Author:
mb Version 2.0 of this class

Constructor Summary
ShooterSprite(java.awt.Dimension dimensionOfDrawingRegion)
          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
 int getHeight()
          This method returns the height of the bounding box that contains this sprite
 java.awt.Point getShooterTip()
          Returns the point that corresponds to the tip of this shooter sprite (e.g., the location from which projectiles should be issued).
 int getWidth()
          This method returns the width of the bounding box that contains this sprite
 void moveDown()
          Move this sprite down one "vertical unit" (the size of this unit is determined by a class attribute).
 void moveLeft()
          Move this sprite left one "horizontal unit" (the size of this unit is determined by a class attribute).
 void moveRight()
          Move this sprite right one "horizontal unit" (the size of this unit is determined by a class attribute).
 void moveUp()
          Move this sprite up one "vertical unit" (the size of this unit is determined by a class attribute).
 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

ShooterSprite

public ShooterSprite(java.awt.Dimension dimensionOfDrawingRegion)
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

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

getWidth

public int getWidth()
This method returns the width of the bounding box that contains this sprite

Returns:
as described above

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

getHeight

public int getHeight()
This method returns the height of the bounding box that contains this sprite

Returns:
as described above

getShooterTip

public java.awt.Point getShooterTip()
Returns the point that corresponds to the tip of this shooter sprite (e.g., the location from which projectiles should be issued).

Returns:
as specified above

moveUp

public void moveUp()
Move this sprite up one "vertical unit" (the size of this unit is determined by a class attribute).


moveDown

public void moveDown()
Move this sprite down one "vertical unit" (the size of this unit is determined by a class attribute).


moveLeft

public void moveLeft()
Move this sprite left one "horizontal unit" (the size of this unit is determined by a class attribute).


moveRight

public void moveRight()
Move this sprite right one "horizontal unit" (the size of this unit is determined by a class attribute).