| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package model.objects;
- import java.awt.Graphics2D;
- import java.awt.Shape;
- import java.awt.geom.Path2D;
- public class ShootingLine {
- private Path2D.Double line;
- private int startx,starty, length;
- public ShootingLine(int startx, int starty){
- line = new Path2D.Double();
- this.startx = startx;
- this.starty = starty;
- }
- public void setLength(int length){
- line = new Path2D.Double();
- line.moveTo(startx, starty);
- int tempy = starty;
- for(int i = 0; i < length; i++){
- line.curveTo(startx + 10, tempy- 10, startx - 10, tempy - 20, startx, tempy-30);
- tempy -= 30;
- }
- this.length = length;
- }
-
- public void paint(Graphics2D g2d)
- {
- g2d.draw(line);
- g2d.drawLine(startx, getMaxHeight(), startx+8, getMaxHeight()+15);
- g2d.drawLine(startx, getMaxHeight(), startx-8, getMaxHeight()+15);
-
- }
-
- public int getLength(){
- return length;
- }
-
- public Path2D getLine(){
- return line;
- }
-
- public int getMaxHeight(){
- return starty - length * 30;
- }
-
- }
|