diff --git a/src/main/java/resources/Acceleration.java b/src/main/java/resources/Acceleration.java index f7d33d4..69f1a18 100644 --- a/src/main/java/resources/Acceleration.java +++ b/src/main/java/resources/Acceleration.java @@ -2,30 +2,30 @@ public class Acceleration { private double massValue; - private Vector2 forceValue; + private Pair forceValue; private Velocity velocity; private Onground onground; - private Vector2 value; + private Pair value; public void updateByMass(double mass) { this.massValue = mass; - Vector2 temp_l0; + Pair temp_l0; if (this.onground.getOnground()) { - temp_l0 = new Vector2((forceValue.getX() / mass), 0.0); + temp_l0 = new Pair((forceValue.getFirst() / mass), 0.0); } else { - temp_l0 = new Vector2((forceValue.getX() / mass), (forceValue.getY() / mass)); + temp_l0 = new Pair((forceValue.getFirst() / mass), (forceValue.getSecond() / mass)); } value = temp_l0; velocity.updateByAcceleration(value); } - public void updateByForce(Vector2 force) { + public void updateByForce(Pair force) { this.forceValue = force; - Vector2 temp_l1; + Pair temp_l1; if (this.onground.getOnground()) { - temp_l1 = new Vector2((force.getX() / massValue), 0.0); + temp_l1 = new Pair((force.getFirst() / massValue), 0.0); } else { - temp_l1 = new Vector2((force.getX() / massValue), (force.getY() / massValue)); + temp_l1 = new Pair((force.getFirst() / massValue), (force.getSecond() / massValue)); } value = temp_l1; velocity.updateByAcceleration(value); @@ -36,7 +36,7 @@ this.onground = onground; } - public Vector2 getValue() { + public Pair getValue() { return value; } } \ No newline at end of file diff --git a/src/main/java/resources/Clear.java b/src/main/java/resources/Clear.java index 8076814..da506e7 100644 --- a/src/main/java/resources/Clear.java +++ b/src/main/java/resources/Clear.java @@ -9,7 +9,7 @@ public boolean getClear() { boolean temp_l4; - if ((this.position.getValue().getX() > 100.0)) { + if (((Double)this.position.getValue().getFirst() > 100.0)) { temp_l4 = true; } else { temp_l4 = false; diff --git a/src/main/java/resources/Force.java b/src/main/java/resources/Force.java index 5ee523e..b660c67 100644 --- a/src/main/java/resources/Force.java +++ b/src/main/java/resources/Force.java @@ -2,18 +2,18 @@ public class Force { private Acceleration acceleration; - private Vector2 value; + private Pair value; public Force(Acceleration acceleration) { this.acceleration = acceleration; } public void gravity(double y) { - this.value = new Vector2(0.0, y); + this.value = new Pair(0.0, y); acceleration.updateByForce(value); } - public Vector2 getValue() { + public Pair getValue() { return value; } } \ No newline at end of file diff --git a/src/main/java/resources/Gameover.java b/src/main/java/resources/Gameover.java index 9f95b01..4d3bdba 100644 --- a/src/main/java/resources/Gameover.java +++ b/src/main/java/resources/Gameover.java @@ -9,7 +9,7 @@ public boolean getGameover() { boolean temp_l6; - if ((this.position.getValue().getY() < -(1.0))) { + if (((Double)this.position.getValue().getSecond() < -(1.0))) { temp_l6 = true; } else { temp_l6 = false; diff --git a/src/main/java/resources/JumpGame.java b/src/main/java/resources/JumpGame.java index 6689e0e..c655bb4 100644 --- a/src/main/java/resources/JumpGame.java +++ b/src/main/java/resources/JumpGame.java @@ -30,11 +30,11 @@ this.mass.setValue(x); } - public Vector2 getAcceleration() { + public Pair getAcceleration() { return acceleration.getValue(); } - public Vector2 getMove() { + public Pair getMove() { return move.getValue(); } @@ -50,15 +50,15 @@ return ground.getValue(); } - public Vector2 getForce() { + public Pair getForce() { return force.getValue(); } - public Vector2 getVelocity() { + public Pair getVelocity() { return velocity.getValue(); } - public Vector2 getPosition() { + public Pair getPosition() { return position.getValue(); } diff --git a/src/main/java/resources/Move.java b/src/main/java/resources/Move.java index 20be320..44f0d3f 100644 --- a/src/main/java/resources/Move.java +++ b/src/main/java/resources/Move.java @@ -2,22 +2,22 @@ public class Move { private Velocity velocity; - private Vector2 value; + private Pair value; public Move(Velocity velocity) { this.velocity = velocity; } public void moveX(double x) { - this.value = new Vector2(x, this.value.getY()); + this.value = new Pair(x, this.value.getSecond()); velocity.updateByMove(value); } public void moveY(double y) { - this.value = new Vector2(this.value.getX(), y); + this.value = new Pair(this.value.getFirst(), y); } - public Vector2 getValue() { + public Pair getValue() { return value; } } \ No newline at end of file diff --git a/src/main/java/resources/Onground.java b/src/main/java/resources/Onground.java index de8ece5..3b5fa82 100644 --- a/src/main/java/resources/Onground.java +++ b/src/main/java/resources/Onground.java @@ -10,5 +10,5 @@ } public boolean getOnground() { - return ((this.ground.getValue() == true) && (this.position.getValue().getY() <= 0.0)); } + return ((this.ground.getValue() == true) && ((Double)this.position.getValue().getSecond() <= 0.0)); } } \ No newline at end of file diff --git a/src/main/java/resources/Pair.java b/src/main/java/resources/Pair.java new file mode 100644 index 0000000..29d3dbe --- /dev/null +++ b/src/main/java/resources/Pair.java @@ -0,0 +1,19 @@ +package resources; + +public class Pair { + private T first; + private T second; + + public Pair(T first, T second) { + this.first = first; + this.second = second; + } + + public T getFirst() { + return this.first; + } + + public T getSecond() { + return this.second; + } +} diff --git a/src/main/java/resources/Position.java b/src/main/java/resources/Position.java index d890660..9d59e22 100644 --- a/src/main/java/resources/Position.java +++ b/src/main/java/resources/Position.java @@ -2,14 +2,14 @@ public class Position { private Ground ground; - private Vector2 value; + private Pair value; - 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); + public void updateByVelocity(Pair velocity) { + Pair temp_l3; + if (((this.ground.getValue() == true) && ((this.value.getSecond() + (0.01 * velocity.getSecond())) < 0.0))) { + temp_l3 = new Pair((this.value.getFirst() + (0.01 * velocity.getFirst())), 0.0); } else { - temp_l3 = new Vector2((this.value.getX() + (0.01 * velocity.getX())), (this.value.getY() + (0.01 * velocity.getY()))); + temp_l3 = new Pair((this.value.getFirst() + (0.01 * velocity.getFirst())), (this.value.getSecond() + (0.01 * velocity.getSecond()))); } value = temp_l3; } @@ -18,7 +18,7 @@ this.ground = ground; } - public Vector2 getValue() { + public Pair getValue() { return value; } } \ No newline at end of file diff --git a/src/main/java/resources/Vector2.java b/src/main/java/resources/Vector2.java deleted file mode 100644 index 8b97696..0000000 --- a/src/main/java/resources/Vector2.java +++ /dev/null @@ -1,19 +0,0 @@ -package resources; - -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/main/java/resources/Velocity.java b/src/main/java/resources/Velocity.java index fcae09b..ec95413 100644 --- a/src/main/java/resources/Velocity.java +++ b/src/main/java/resources/Velocity.java @@ -1,16 +1,18 @@ package resources; +import com.sun.org.apache.xerces.internal.dom.DOMOutputImpl; + public class Velocity { - private Vector2 moveValue; - private Vector2 accelerationValue; + private Pair moveValue; + private Pair accelerationValue; private Position position; private Onground onground; - private Vector2 value; + private Pair value; - public void updateByMove(Vector2 move) { + public void updateByMove(Pair move) { this.moveValue = move; - Vector2 temp_l2; - if ((this.onground.getOnground() && (move.getY() >= 0.0))) { + Pair temp_l2; + if ((this.onground.getOnground() && (move.getSecond() >= 0.0))) { temp_l2 = move; } else { temp_l2 = this.value; @@ -19,13 +21,13 @@ position.updateByVelocity(value); } - public void updateByAcceleration(Vector2 acceleration) { + public void updateByAcceleration(Pair acceleration) { this.accelerationValue = acceleration; - 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); + Pair temp_l5; + if ((this.onground.getOnground() && (this.value.getSecond() < 0.0))) { + temp_l5 = new Pair((this.value.getFirst() + (0.01 * acceleration.getFirst())), 0.0); } else { - temp_l5 = new Vector2((this.value.getX() + (0.01 * acceleration.getX())), (this.value.getY() + (0.01 * acceleration.getY()))); + temp_l5 = new Pair((this.value.getFirst() + (0.01 * acceleration.getFirst())), (this.value.getSecond() + (0.01 * acceleration.getSecond()))); } value = temp_l5; position.updateByVelocity(value); @@ -36,7 +38,7 @@ this.onground = onground; } - public Vector2 getValue() { + public Pair getValue() { return value; } } \ No newline at end of file