Class Laser

java.lang.Object
  extended by Laser

public class Laser
extends java.lang.Object

A Laser that can move and draw itself


Constructor Summary
Laser(Defender d)
          Constructs a new Laser based on the position of the Defender
Laser(int startXPosition, int startYPosition, int xVelocity, int yVelocity)
          Constructs a Laser based on the given location and velocity
 
Method Summary
 int getXPosition()
          Get the current x coordinate of the center of this Laser.
 int getYPosition()
          Get the current y coordinate of the center of this Laser.
 boolean isDefenderLaser()
          Returns true if the Defender fired this Laser
 void paint(java.awt.Graphics g)
          Paint this Laser onto the given Graphics object
 boolean removeMeFromGame()
          Returns true if this Laser has left the game area.
 void takeOneStep()
          Updates the position of the Laser for the next time it is redrawn.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Laser

public Laser(int startXPosition,
             int startYPosition,
             int xVelocity,
             int yVelocity)
Constructs a Laser based on the given location and velocity

Parameters:
startXPosition - the starting x position
startYPosition - the starting y position
xVelocity - the starting x velocity
yVelocity - the starting y velocity

Laser

public Laser(Defender d)
Constructs a new Laser based on the position of the Defender

Parameters:
d - the Defender
Method Detail

isDefenderLaser

public boolean isDefenderLaser()
Returns true if the Defender fired this Laser

Returns:
true if the Defender fired this Laser

takeOneStep

public void takeOneStep()
Updates the position of the Laser for the next time it is redrawn.


removeMeFromGame

public boolean removeMeFromGame()
Returns true if this Laser has left the game area.

Returns:
true if this Laser has left the game area.

paint

public void paint(java.awt.Graphics g)
Paint this Laser onto the given Graphics object

Parameters:
g - the Graphics object to draw onto

getXPosition

public int getXPosition()
Get the current x coordinate of the center of this Laser.

Returns:
The current x coordinate of the center of this Laser.

getYPosition

public int getYPosition()
Get the current y coordinate of the center of this Laser.

Returns:
The current y coordinate of the center of this Laser.