diff --git a/src/main/java/core/math/Vector2D.java b/src/main/java/core/math/Vector2D.java index fa8050c..a2faefb 100644 --- a/src/main/java/core/math/Vector2D.java +++ b/src/main/java/core/math/Vector2D.java @@ -4,7 +4,7 @@ package core.math; import java.awt.*; /** - * A 2-dimensional Vector that can be used to store position or velocity + * A 2-dimensional Vector that can be used to store position or velocity or size or whatever */ public class Vector2D { diff --git a/src/main/java/core/objects/base/DebugPos.java b/src/main/java/core/objects/base/DebugPos.java index 3299c63..d13c840 100644 --- a/src/main/java/core/objects/base/DebugPos.java +++ b/src/main/java/core/objects/base/DebugPos.java @@ -1,5 +1,6 @@ package core.objects.base; +import core.math.Coords; import core.math.Vector2D; import core.objects.core.GameObject; diff --git a/src/main/java/core/objects/core/GameObject.java b/src/main/java/core/objects/core/GameObject.java index 3ebe307..5bb79a4 100644 --- a/src/main/java/core/objects/core/GameObject.java +++ b/src/main/java/core/objects/core/GameObject.java @@ -9,7 +9,7 @@ import java.awt.*; /** * The GameObject class is the superclass of every GameObject that can be displayed on screen. It has the 2 - * {@link #update()} and {@link #draw(Graphics2D)} methods that have to be + * {@link #update()} and {@link #draw(Graphics2D)} methods that have to be overridden */ public abstract class GameObject implements Drawable { @@ -99,7 +99,12 @@ public abstract class GameObject implements Drawable { Vector2D abs; - abs = (arg.contains("center")) ? Coords.getWorldCoords(getCenterPosition()) : Coords.getWorldCoords(position); + if(arg.contains("center")){ + abs = Coords.getWorldCoords(new Vector2D(position.x - size.x / 2, position.y - size.y / 2)); + } else { + abs = Coords.getWorldCoords(position); + } + Vector2D sizeAbs = Coords.getWorldCoords(size); g2d.setPaint(mainColor); diff --git a/src/main/java/objects/ships/Turret.java b/src/main/java/objects/ships/Turret.java index 86e480d..a80ca15 100644 --- a/src/main/java/objects/ships/Turret.java +++ b/src/main/java/objects/ships/Turret.java @@ -81,8 +81,8 @@ public class Turret extends GameObject { Point msLoc = master.getMouseLocation(); Vector2D mouseRel = Coords.getMapCoordsFromWorld(Vector2D.fromPoint(msLoc)); //100 correct - Vector2D center = battleShip.getMapCoords(getCenterPosition()); - double targetRotation = -Math.atan2(center.x - mouseRel.x, center.y - mouseRel.y); + Vector2D centerMap = battleShip.getMapCoords(getCenterPosition()); + double targetRotation = -Math.atan2(centerMap.x - mouseRel.x, centerMap.y - mouseRel.y); rotation = ExMath.angleLerp(rotation, targetRotation, ROTATION_SPEED); @@ -98,10 +98,9 @@ public class Turret extends GameObject { lastShot = System.currentTimeMillis(); Vector2D shellVel = Vector2D.getUnitVector(rotation).negative().multiply(SHELL_SPEED); - master.debugPos(battleShip.getMapCoords(center)); - master.debugPos(center); + master.debugPos(centerMap); Vector2D pos = Vector2D.rotateAround( - battleShip.getMapCoords(center), + centerMap, spawnPosNR, rotation); diff --git a/target/classes/BasicEx$1.class b/target/classes/BasicEx$1.class deleted file mode 100644 index fd3f4b9..0000000 Binary files a/target/classes/BasicEx$1.class and /dev/null differ diff --git a/target/classes/BasicEx.class b/target/classes/BasicEx.class deleted file mode 100644 index 296712b..0000000 Binary files a/target/classes/BasicEx.class and /dev/null differ diff --git a/target/classes/core/Master.class b/target/classes/core/Master.class index e0c9a96..4100c4a 100644 Binary files a/target/classes/core/Master.class and b/target/classes/core/Master.class differ diff --git a/target/classes/objects/DebugPos.class b/target/classes/objects/DebugPos.class deleted file mode 100644 index 1dfedb2..0000000 Binary files a/target/classes/objects/DebugPos.class and /dev/null differ diff --git a/target/classes/objects/ships/BattleShip.class b/target/classes/objects/ships/BattleShip.class index 4318895..8afe046 100644 Binary files a/target/classes/objects/ships/BattleShip.class and b/target/classes/objects/ships/BattleShip.class differ diff --git a/target/classes/objects/ships/Shell.class b/target/classes/objects/ships/Shell.class index 5c94f50..d603cab 100644 Binary files a/target/classes/objects/ships/Shell.class and b/target/classes/objects/ships/Shell.class differ diff --git a/target/classes/objects/ships/Turret.class b/target/classes/objects/ships/Turret.class index 47a3d55..9ed69a8 100644 Binary files a/target/classes/objects/ships/Turret.class and b/target/classes/objects/ships/Turret.class differ diff --git a/target/classes/objects/world/Grid.class b/target/classes/objects/world/Grid.class index c26fd1e..488ac1a 100644 Binary files a/target/classes/objects/world/Grid.class and b/target/classes/objects/world/Grid.class differ