diff --git a/OGP1718-Worms/src/worms/model/GameObject.java b/OGP1718-Worms/src/worms/model/GameObject.java new file mode 100644 index 0000000..f6a823b --- /dev/null +++ b/OGP1718-Worms/src/worms/model/GameObject.java @@ -0,0 +1,63 @@ +package worms.model; + +import worms.util.Coordinate; + +import static java.lang.Math.PI; +import static java.lang.Math.pow; +import static java.lang.Math.round; + +public abstract class GameObject { + + public GameObject(World world, Coordinate location, double radius) { + + this.world = world; + this.location = location; + this.radius = radius; + } + + private World world; + + public World getWorld() { + return this.world; + } + public void setWorld(World world) { + this.world = world; + } + + + public boolean isTerminated() { + return this.terminated; + } + public void terminate() { + this.terminated = true; + } + private boolean terminated = false; + + + + private Coordinate location; + public double[] getLocation() { + return null; + } + + private void setLocation(Coordinate location) { + this.location = location; + } + + private double radius; + public double getRadius(){ + return this.radius; + } + abstract void setRadius(); + + + + private double mass; + public double getMass() { + return this.mass; + } + private void setMass() { + this.mass = (double) round(rho * (4.0 / 3.0 * PI * pow(radius, 3))); + } + private final double rho = 0; +} \ No newline at end of file diff --git a/OGP1718-Worms/src/worms/model/World.java b/OGP1718-Worms/src/worms/model/World.java index 575df5a..8655299 100644 --- a/OGP1718-Worms/src/worms/model/World.java +++ b/OGP1718-Worms/src/worms/model/World.java @@ -127,7 +127,7 @@ public class World { if (location[0] / lengthX >= getMap()[0].length || location[0] < 0.0 || location[1] / lengthY >= getMap().length || location[1] < 0.0) { - return true; + return false; } return this.map[(int) Math.floor(location[1] / lengthY)][(int) Math.floor(location[0] / lengthX)]; } diff --git a/OGP1718-Worms/src/worms/model/Worm.java b/OGP1718-Worms/src/worms/model/Worm.java index 561d2be..c3afa9b 100644 --- a/OGP1718-Worms/src/worms/model/Worm.java +++ b/OGP1718-Worms/src/worms/model/Worm.java @@ -1,7 +1,6 @@ package worms.model; import be.kuleuven.cs.som.annotate.*; -import jdk.jshell.spi.ExecutionControl; import worms.util.Coordinate; import worms.util.IllegalNameException; @@ -239,8 +238,6 @@ public class Worm { // endregion - - // region Shape mass/radius //===================================================================================