public class Laser
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private java.awt.Color |
color |
private boolean |
defenderSide |
private static double |
DIAG_ANGLE |
private static double |
SHOT_RADIUS |
private int |
xPosition |
private int |
xVelocity |
private int |
yPosition |
private int |
yVelocity |
| Constructor and Description |
|---|
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
|
| Modifier and Type | Method and Description |
|---|---|
java.awt.Color |
getColor()
Get the current color of this Laser.
|
boolean |
getDefenderSide()
Get the current defender side of this Laser.
|
int |
getXPosition()
Get the current x coordinate of the center of this Laser.
|
int |
getXVelocity()
Get the current x Velocity of this Laser.
|
int |
getYPosition()
Get the current y coordinate of the center of this Laser.
|
int |
getYVelocity()
Get the current y Velocity 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
|
private static java.awt.Point |
polar(int origX,
int origY,
double angle,
double radius) |
boolean |
removeMeFromGame()
Returns true if this Laser has left the game area.
|
(package private) void |
setColor(java.awt.Color c)
Sets the current color of this Laser.
|
(package private) void |
setDefendersSide(boolean s)
Sets the current defenderSide of this Laser.
|
(package private) void |
setXPosition(int x)
Sets the current x coordinate of the center of this Laser.
|
(package private) void |
setXVelocity(int x)
Sets the current x Velocity of this Laser.
|
(package private) void |
setYPosition(int y)
Sets the current y coordinate of the center of this Laser.
|
(package private) void |
setYVelocity(int y)
Sets the current y Velocity of this Laser.
|
void |
takeOneStep()
Updates the position of the Laser for the next time it is redrawn.
|
private static final double DIAG_ANGLE
private static final double SHOT_RADIUS
private java.awt.Color color
private int xPosition
private int yPosition
private int yVelocity
private int xVelocity
private boolean defenderSide
public Laser(int startXPosition,
int startYPosition,
int xVelocity,
int yVelocity)
startXPosition - the starting x positionstartYPosition - the starting y positionxVelocity - the starting x velocityyVelocity - the starting y velocitypublic Laser(Defender d)
d - the Defenderpublic boolean isDefenderLaser()
public void takeOneStep()
public boolean removeMeFromGame()
public void paint(java.awt.Graphics g)
g - the Graphics object to draw ontoprivate static java.awt.Point polar(int origX,
int origY,
double angle,
double radius)
public int getXPosition()
void setXPosition(int x)
x - The new x coordinate of the center of this Laser.public int getYPosition()
void setYPosition(int y)
y - The new y coordinate of the center of this Laser.public java.awt.Color getColor()
void setColor(java.awt.Color c)
c - The new color of this Laser.public int getXVelocity()
void setXVelocity(int x)
x - The new x Velocity of this Laser.public int getYVelocity()
void setYVelocity(int y)
y - The new y Velocity of this Laser.void setDefendersSide(boolean s)
s - The new defenderSide of this Laser.public boolean getDefenderSide()