From 383bf84152438d89b9e27e727c6c3342a242b303 Mon Sep 17 00:00:00 2001 From: Leen Dereu Date: Fri, 4 May 2018 14:28:28 +0200 Subject: [PATCH 1/3] Worm --- OGP1718-Worms/src/worms/model/Worm.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/OGP1718-Worms/src/worms/model/Worm.java b/OGP1718-Worms/src/worms/model/Worm.java index 44e1851..2855e06 100644 --- a/OGP1718-Worms/src/worms/model/Worm.java +++ b/OGP1718-Worms/src/worms/model/Worm.java @@ -1229,6 +1229,13 @@ public class Worm extends GameObject { } + public void createRifle() { + + } + + public void createBazooka() { + + } // =================================================================================== // endregion } From 8c7a078aa1e1d1d16b94fa72dc83279ad0432e8a Mon Sep 17 00:00:00 2001 From: Leen Dereu Date: Fri, 4 May 2018 15:15:50 +0200 Subject: [PATCH 2/3] Worm: projectile --- OGP1718-Worms/src/worms/model/Worm.java | 43 ++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/OGP1718-Worms/src/worms/model/Worm.java b/OGP1718-Worms/src/worms/model/Worm.java index 2855e06..a2a9d0f 100644 --- a/OGP1718-Worms/src/worms/model/Worm.java +++ b/OGP1718-Worms/src/worms/model/Worm.java @@ -1225,16 +1225,49 @@ public class Worm extends GameObject { } // region firing and projectiles //=================================================================================== + private double[] locationProj; + private double massProj; + private long hitpointsProj; + private double forceProj; + public void fire() { - + if (getActionPoints() >= 30 && getWorld() != null) { + Random r = new Random(); + int random = r.nextInt((1 - 0) + 1); + locationProj[0] = cos(getOrientation())*getRadius(); + locationProj[1] = sin(getOrientation())*getRadius(); + if (random == 0) { + propertiesRifle(); + decreaseActionPoints(10); + } + else { + propertiesBazooka(); + decreaseActionPoints(25); + } + new Projectile(this.getWorld(), locationProj, massProj, hitpointsProj, forceProj); + } } - public void createRifle() { - + public void propertiesRifle() { + massProj = 10; + forceProj = 1.5; + Random r = new Random(); + hitpointsProj = 0 + r.nextInt((10-0)/2) *2; } - public void createBazooka() { - + public void propertiesBazooka() { + massProj = 300; + forceProj = 2.5 + getActionPoints()/8; + Random r = new Random(); + hitpointsProj = 0 + r.nextInt((10-0)/(2+1)) *(2+1); + } + + public void hitByRifle() { + decreaseHitPoints(hitpointsProj); + } + + public void hitByBazooka() { + decreaseHitPoints(hitpointsProj * (long) forceProj); } // =================================================================================== // endregion From faf5866aa5dcd94104908aad745c30ccbb2199a6 Mon Sep 17 00:00:00 2001 From: Leen Dereu Date: Fri, 4 May 2018 15:31:49 +0200 Subject: [PATCH 3/3] Class Projectile --- OGP1718-Worms/src/worms/model/Projectile.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OGP1718-Worms/src/worms/model/Projectile.java b/OGP1718-Worms/src/worms/model/Projectile.java index 412c49e..79bf361 100644 --- a/OGP1718-Worms/src/worms/model/Projectile.java +++ b/OGP1718-Worms/src/worms/model/Projectile.java @@ -27,4 +27,6 @@ public class Projectile extends GameObject { public void setForce(double force) { this.force = force; } + + }