From 306b84881fc129da033b34a548dee2247cc9c3e2 Mon Sep 17 00:00:00 2001 From: Nilstrieb Date: Fri, 1 Jan 2021 18:12:23 +0100 Subject: [PATCH] turret bullet spawn --- src/main/java/custom/objects/ships/Turret.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/custom/objects/ships/Turret.java b/src/main/java/custom/objects/ships/Turret.java index 4dc5692..69e228f 100644 --- a/src/main/java/custom/objects/ships/Turret.java +++ b/src/main/java/custom/objects/ships/Turret.java @@ -77,12 +77,14 @@ public class Turret extends GameObject { int barrelSpacing = (int) (size.x / (barrelAmount + 1)); for (int i = 0; i < barrelAmount; i++) { - int barrelX = (int) (position.x + (i + 1) * barrelSpacing); - int frontPosY = (int) (position.y - size.x / 2); - - Vector2D spawnPosNR = getMapCoords(new Vector2D(barrelX, frontPosY)); if (Input.isMousePressed()) { + + double barrelX = position.x + (i + 1) * barrelSpacing; + double frontPosY = position.y - size.x / 2; + + Vector2D spawnPosNR = getMapCoords(new Vector2D(barrelX, frontPosY)); + lastShot = System.currentTimeMillis(); Vector2D shellVel = Vector2D.getUnitVector(rotation).negative().multiply(SHELL_SPEED);