import java.lang.Math; import java.awt.*; import java.awt.geom.*; public class Laser { private double x; private double y; private double direction; private final static double LENGTH = 10.0; private final static double DISTANCE = 5.0; private final static Color LASER_COLOR = Color.red; public Laser(double x_, double y_, double direction_) { x = x_; y = y_; direction = direction_; } public void move() { x += DISTANCE * Math.cos(direction); y += DISTANCE * Math.sin(direction); } public void draw(Graphics2D g2) { g2.setColor(LASER_COLOR); g2.setStroke(new BasicStroke(2)); g2.draw(new Line2D.Double(x, y, x + LENGTH * Math.cos(direction), y + LENGTH * Math.sin(direction))); } public double getX() { return x; } public double getY() { return y; } public boolean isHitting(Shooter s) { return s.isHitting(x, y, x + LENGTH * Math.cos(direction), y + LENGTH * Math.sin(direction)); } }