diff --git a/src/Acceleration.java b/src/Acceleration.java index c60c686..aa03887 100644 --- a/src/Acceleration.java +++ b/src/Acceleration.java @@ -2,40 +2,41 @@ public class Acceleration { private double massValue; - private Map.Entry forceValue; + private Vector2 forceValue; private Velocity velocity; private Onground onground; - private Map.Entry value; + private Vector2 value; public void updateByMass(double mass) { this.massValue = mass; - Map.Entry temp_l0; + Vector2 temp_l0; if (this.onground.getOnground()) { - temp_l0 = new AbstractMap.SimpleEntry<>((forceValue.getKey() / mass), 0.0); + temp_l0 = new Vector2((forceValue.getX() / mass), 0.0); } else { - temp_l0 = new AbstractMap.SimpleEntry<>((forceValue.getKey() / mass), (forceValue.getValue() / mass)); + temp_l0 = new Vector2((forceValue.getX() / mass), (forceValue.getY() / mass)); } value = temp_l0; velocity.updateByAcceleration(value); } - public void updateByForce(Map.Entry force) { + public void updateByForce(Vector2 force) { this.forceValue = force; - Map.Entry temp_l1; + Vector2 temp_l1; if (this.onground.getOnground()) { - temp_l1 = new AbstractMap.SimpleEntry<>((force.getKey() / massValue), 0.0); + temp_l1 = new Vector2((force.getX() / massValue), 0.0); } else { - temp_l1 = new AbstractMap.SimpleEntry<>((force.getKey() / massValue), (force.getValue() / massValue)); + temp_l1 = new Vector2((force.getX() / massValue), (force.getY() / massValue)); } value = temp_l1; velocity.updateByAcceleration(value); } public Acceleration(Velocity velocity, Onground onground) { + this.velocity = velocity; this.onground = onground; } - public Map.Entry getValue() { + public Vector2 getValue() { return value; } } \ No newline at end of file diff --git a/src/Clear.java b/src/Clear.java index fc4d855..163f30c 100644 --- a/src/Clear.java +++ b/src/Clear.java @@ -7,7 +7,7 @@ public boolean getClear() { boolean temp_l4; - if ((this.position.getValue().getKey() > 100.0)) { + if ((this.position.getValue().getX() > 100.0)) { temp_l4 = true; } else { temp_l4 = false; diff --git a/src/Force.java b/src/Force.java index 68fb3f7..1ae867f 100644 --- a/src/Force.java +++ b/src/Force.java @@ -2,18 +2,18 @@ public class Force { private Acceleration acceleration; - private Map.Entry value; + private Vector2 value; public Force(Acceleration acceleration) { this.acceleration = acceleration; } public void gravity(double y) { - this.value = new AbstractMap.SimpleEntry<>(0.0, y); + this.value = new Vector2(0.0, y); acceleration.updateByForce(value); } - public Map.Entry getValue() { + public Vector2 getValue() { return value; } } \ No newline at end of file diff --git a/src/Gameover.java b/src/Gameover.java index 15d7af5..9a9f0ca 100644 --- a/src/Gameover.java +++ b/src/Gameover.java @@ -7,7 +7,7 @@ public boolean getGameover() { boolean temp_l6; - if ((this.position.getValue().getValue() < -(1.0))) { + if ((this.position.getValue().getY() < -(1.0))) { temp_l6 = true; } else { temp_l6 = false; diff --git a/src/JumpGame.java b/src/JumpGame.java index ae0aca6..9dad6de 100644 --- a/src/JumpGame.java +++ b/src/JumpGame.java @@ -30,11 +30,11 @@ this.mass.setValue(x); } - public Map.Entry getAcceleration() { + public Vector2 getAcceleration() { return acceleration.getValue(); } - public Map.Entry getMove() { + public Vector2 getMove() { return move.getValue(); } @@ -50,15 +50,15 @@ return ground.getValue(); } - public Map.Entry getForce() { + public Vector2 getForce() { return force.getValue(); } - public Map.Entry getVelocity() { + public Vector2 getVelocity() { return velocity.getValue(); } - public Map.Entry getPosition() { + public Vector2 getPosition() { return position.getValue(); } diff --git a/src/Move.java b/src/Move.java index bbd2013..f30bd7d 100644 --- a/src/Move.java +++ b/src/Move.java @@ -2,22 +2,22 @@ public class Move { private Velocity velocity; - private Map.Entry value; + private Vector2 value; public Move(Velocity velocity) { this.velocity = velocity; } public void moveX(double x) { - this.value = new AbstractMap.SimpleEntry<>(x, this.value.getValue()); + this.value = new Vector2(x, this.value.getY()); velocity.updateByMove(value); } public void moveY(double y) { - this.value = new AbstractMap.SimpleEntry<>(this.value.getKey(), y); + this.value = new Vector2(this.value.getX(), y); } - public Map.Entry getValue() { + public Vector2 getValue() { return value; } } \ No newline at end of file diff --git a/src/Onground.java b/src/Onground.java index 751041f..a70fdbc 100644 --- a/src/Onground.java +++ b/src/Onground.java @@ -8,6 +8,5 @@ } public boolean getOnground() { - return ((this.ground.getValue() == true) && (this.position.getValue().getValue() <= 0.0)); - } + return ((this.ground.getValue() == true) && (this.position.getValue().getY() <= 0.0)); } } \ No newline at end of file diff --git a/src/Position.java b/src/Position.java index dc8cbc5..483e61f 100644 --- a/src/Position.java +++ b/src/Position.java @@ -2,14 +2,14 @@ public class Position { private Ground ground; - private Map.Entry value; + private Vector2 value; - public void updateByVelocity(Map.Entry velocity) { - Map.Entry temp_l3; - if (((this.ground.getValue() == true) && ((this.value.getValue() + (0.01 * velocity.getValue())) < 0.0))) { - temp_l3 = new AbstractMap.SimpleEntry<>((this.value.getKey() + (0.01 * velocity.getKey())), 0.0); + public void updateByVelocity(Vector2 velocity) { + Vector2 temp_l3; + if (((this.ground.getValue() == true) && ((this.value.getY() + (0.01 * velocity.getY())) < 0.0))) { + temp_l3 = new Vector2((this.value.getX() + (0.01 * velocity.getX())), 0.0); } else { - temp_l3 = new AbstractMap.SimpleEntry<>((this.value.getKey() + (0.01 * velocity.getKey())), (this.value.getValue() + (0.01 * velocity.getValue()))); + temp_l3 = new Vector2((this.value.getX() + (0.01 * velocity.getX())), (this.value.getY() + (0.01 * velocity.getY()))); } value = temp_l3; } @@ -18,7 +18,7 @@ this.ground = ground; } - public Map.Entry getValue() { + public Vector2 getValue() { return value; } } \ No newline at end of file diff --git a/src/Vector2.java b/src/Vector2.java new file mode 100644 index 0000000..26ddd9c --- /dev/null +++ b/src/Vector2.java @@ -0,0 +1,17 @@ +public class Vector2 { + private double x; + private double y; + + public Vector2(double x, double y) { + this.x = x; + this.y = y; + } + + public double getX() { + return this.x; + } + + public double getY() { + return this.y; + } +} diff --git a/src/Velocity.java b/src/Velocity.java index 860b2af..db011e9 100644 --- a/src/Velocity.java +++ b/src/Velocity.java @@ -1,16 +1,16 @@ import java.util.*; public class Velocity { - private Map.Entry moveValue; - private Map.Entry accelerationValue; + private Vector2 moveValue; + private Vector2 accelerationValue; private Position position; private Onground onground; - private Map.Entry value; + private Vector2 value; - public void updateByMove(Map.Entry move) { + public void updateByMove(Vector2 move) { this.moveValue = move; - Map.Entry temp_l2; - if ((this.onground.getOnground() && (move.getValue() >= 0.0))) { + Vector2 temp_l2; + if ((this.onground.getOnground() && (move.getY() >= 0.0))) { temp_l2 = move; } else { temp_l2 = this.value; @@ -19,13 +19,13 @@ position.updateByVelocity(value); } - public void updateByAcceleration(Map.Entry acceleration) { + public void updateByAcceleration(Vector2 acceleration) { this.accelerationValue = acceleration; - Map.Entry temp_l5; - if ((this.onground.getOnground() && (this.value.getValue() < 0.0))) { - temp_l5 = new AbstractMap.SimpleEntry<>((this.value.getKey() + (0.01 * acceleration.getKey())), 0.0); + Vector2 temp_l5; + if ((this.onground.getOnground() && (this.value.getY() < 0.0))) { + temp_l5 = new Vector2((this.value.getX() + (0.01 * acceleration.getX())), 0.0); } else { - temp_l5 = new AbstractMap.SimpleEntry<>((this.value.getKey() + (0.01 * acceleration.getKey())), (this.value.getValue() + (0.01 * acceleration.getValue()))); + temp_l5 = new Vector2((this.value.getX() + (0.01 * acceleration.getX())), (this.value.getY() + (0.01 * acceleration.getY()))); } value = temp_l5; position.updateByVelocity(value); @@ -36,7 +36,7 @@ this.onground = onground; } - public Map.Entry getValue() { + public Vector2 getValue() { return value; } } \ No newline at end of file