shooting works

This commit is contained in:
nora 2020-12-11 20:29:03 +01:00
parent 0d5397dbe3
commit e2483b30ff
8 changed files with 45 additions and 23 deletions

View file

@ -17,7 +17,7 @@ public class DebugPos extends GameObject {
@Override
public void draw(Graphics2D g2d, int w, Master master) {
g2d.setPaint(Color.green);
g2d.drawOval((int) (position.x + size.x / 2), (int) (position.y + size.y / 2), (int) size.x, (int) size.y);
g2d.drawOval((int) (position.x - size.x / 2), (int) (position.y - size.y / 2), (int) size.x, (int) size.y);
}
@Override

View file

@ -17,9 +17,9 @@ public class BattleShip extends GameObject {
public BattleShip(Color mainColor) {
super(20, 20, 5, 40);
turrets = new ArrayList<>();
turrets.add(new Turret(this, 25, 25, 50, 1));
//turrets.add(new Turret(this, 25, 10, 50, 2));
//turrets.add(new Turret(this, 25, 70, 50, 2));
turrets.add(new Turret(this, 25, 25, 50, 3));
turrets.add(new Turret(this, 25, 10, 50, 2));
turrets.add(new Turret(this, 25, 70, 50, 2));
this.mainColor = mainColor;
}

View file

@ -92,9 +92,7 @@ public class Turret extends GameObject {
lastShot = System.currentTimeMillis();
Vector2D shellVel = new Vector2D(xCenterAbs - msLoc.x, yCenterAbs - msLoc.y).normalized().negative().multiply(SHELL_SPEED);
Vector2D pos = Vector2D.rotateAround(new Vector2D(xCenterAbs, yCenterAbs), new Vector2D(barrelX, frontPosY), rotation, Vector2D.CLOCKWISE);
master.debugPos(pos);
Vector2D pos = Vector2D.rotateAround(new Vector2D(xCenterAbs, yCenterAbs), new Vector2D(barrelX, frontPosY), rotation, Vector2D.COUNTERCLOCKWISE);
master.create(new Shell(pos, new Vector2D(10, 10), shellVel));
}