diff --git a/OGP1718-Worms/src/worms/model/Bazooka.java b/OGP1718-Worms/src/worms/model/Bazooka.java index b697e4b..c9eba80 100644 --- a/OGP1718-Worms/src/worms/model/Bazooka.java +++ b/OGP1718-Worms/src/worms/model/Bazooka.java @@ -26,6 +26,8 @@ public class Bazooka extends Projectile { if (value == 0) value++; else value--; } + double force = getForce(); + value = value* (int) force; super.hitPoints = value; } diff --git a/OGP1718-Worms/src/worms/model/Projectile.java b/OGP1718-Worms/src/worms/model/Projectile.java index 574a857..3595770 100644 --- a/OGP1718-Worms/src/worms/model/Projectile.java +++ b/OGP1718-Worms/src/worms/model/Projectile.java @@ -82,8 +82,7 @@ public abstract class Projectile extends GameObject { private double jumpVelocity() { return getForce() / (getMass() / 1000) * FORCE_TIME; } - - //TODO jumpTimeStep moet nog toegepast worden! + public double getJumpTime(double jumpTimeStep) { World world = getWorld(); @@ -105,7 +104,7 @@ public abstract class Projectile extends GameObject { newLoc = Coordinate.create(x, y); if (! world.isPassable(newLoc, radius) || x < 0 || y < 0 || x > world.getWidth() || y > world.getHeight()) { while (true) { - time -= 0.01; + time -= jumpTimeStep; newLoc = Coordinate.create(loc.getX() + v * time * cos(a), loc.getY() + v * time * sin(a) - (G * time * time) / 2.0); if (newLoc.getX() < 0 || newLoc.getY() < 0 || newLoc.getX() > getWorld().getWidth() || newLoc.getY() > world.getHeight() || world.isAdjacent(newLoc, radius)) { @@ -161,7 +160,14 @@ public abstract class Projectile extends GameObject { terminate(); return; } + setLocation(newLocation); + + for (Worm worm: worms) { + if (this.getDistance(worm) < 0) { + hit(worm); + } + } } private static Coordinate calcLocation(Coordinate wormLocation, double wormOrientation, double wormRadius, double mass) { diff --git a/OGP1718-Worms/tests/worms/model/Part3_FullFacadeTest.java b/OGP1718-Worms/tests/worms/model/Part3_FullFacadeTest.java index cbc11dc..d0f9ad3 100755 --- a/OGP1718-Worms/tests/worms/model/Part3_FullFacadeTest.java +++ b/OGP1718-Worms/tests/worms/model/Part3_FullFacadeTest.java @@ -2437,7 +2437,6 @@ public class Part3_FullFacadeTest { double[] stepLocation = facade.getJumpStep(projectile, 0.1); double[] expectedRifleLocation = new double[] { 2.997, 9.275 }; double[] expectedBazookaLocation = new double[] { 6.114, 3.875 }; - System.out.println(projectile instanceof Rifle); assertEquals("Result must have exactly 2 coordinates", 2, stepLocation.length); assertTrue((Math.abs(stepLocation[0] - expectedRifleLocation[0]) < 0.01) || (Math.abs(stepLocation[0] - expectedBazookaLocation[0]) < 0.01));