diff --git a/README.md b/README.md index e2ab130..7f7d58d 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -resources.JumpGame +entity.JumpGame =============== diff --git a/src/main/java/entity/Acceleration.java b/src/main/java/entity/Acceleration.java new file mode 100644 index 0000000..9c8c010 --- /dev/null +++ b/src/main/java/entity/Acceleration.java @@ -0,0 +1,42 @@ +package entity; + +public class Acceleration { + private double massValue; + private Pair forceValue; + private Velocity velocity; + private Onground onground; + private Pair value; + + public void updateByMass(double mass) { + this.massValue = mass; + Pair temp_l0; + if (this.onground.getOnground()) { + temp_l0 = new Pair((forceValue.getFirst() / mass), 0.0); + } else { + temp_l0 = new Pair((forceValue.getFirst() / mass), (forceValue.getSecond() / mass)); + } + value = temp_l0; + velocity.updateByAcceleration(value); + } + + public void updateByForce(Pair force) { + this.forceValue = force; + Pair temp_l1; + if (this.onground.getOnground()) { + temp_l1 = new Pair((force.getFirst() / massValue), 0.0); + } else { + temp_l1 = new Pair((force.getFirst() / massValue), (force.getSecond() / massValue)); + } + value = temp_l1; + velocity.updateByAcceleration(value); + } + + public Acceleration(Velocity velocity, Onground onground) { + this.velocity = velocity; + this.onground = onground; + } + + public Pair getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/entity/Clear.java b/src/main/java/entity/Clear.java new file mode 100644 index 0000000..67e876d --- /dev/null +++ b/src/main/java/entity/Clear.java @@ -0,0 +1,19 @@ +package entity; + +public class Clear { + private Position position; + + public Clear(Position position) { + this.position = position; + } + + public boolean getClear() { + boolean temp_l4; + if ((this.position.getValue().getFirst() > 100.0)) { + temp_l4 = true; + } else { + temp_l4 = false; + } + return temp_l4; + } +} \ No newline at end of file diff --git a/src/main/java/entity/Force.java b/src/main/java/entity/Force.java new file mode 100644 index 0000000..ba219f0 --- /dev/null +++ b/src/main/java/entity/Force.java @@ -0,0 +1,19 @@ +package entity; + +public class Force { + private Acceleration acceleration; + private Pair value; + + public Force(Acceleration acceleration) { + this.acceleration = acceleration; + } + + public void gravity(double y) { + this.value = new Pair(0.0, y); + acceleration.updateByForce(value); + } + + public Pair getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/entity/Gameover.java b/src/main/java/entity/Gameover.java new file mode 100644 index 0000000..da3eace --- /dev/null +++ b/src/main/java/entity/Gameover.java @@ -0,0 +1,19 @@ +package entity; + +public class Gameover { + private Position position; + + public Gameover(Position position) { + this.position = position; + } + + public boolean getGameover() { + boolean temp_l6; + if ((this.position.getValue().getSecond() < -(1.0))) { + temp_l6 = true; + } else { + temp_l6 = false; + } + return temp_l6; + } +} \ No newline at end of file diff --git a/src/main/java/entity/Ground.java b/src/main/java/entity/Ground.java new file mode 100644 index 0000000..461b542 --- /dev/null +++ b/src/main/java/entity/Ground.java @@ -0,0 +1,9 @@ +package entity; + +public class Ground { + private boolean value; + + public boolean getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/entity/JumpGame.java b/src/main/java/entity/JumpGame.java new file mode 100644 index 0000000..0733d58 --- /dev/null +++ b/src/main/java/entity/JumpGame.java @@ -0,0 +1,76 @@ +package entity; + +public class JumpGame { + private Time time = new Time(); + private Ground ground = new Ground(); + private Position position = new Position(ground); + private Gameover gameover = new Gameover(position); + private Onground onground = new Onground(ground, position); + private Velocity velocity = new Velocity(position, onground); + private Clear clear = new Clear(position); + private Move move = new Move(velocity); + private Acceleration acceleration = new Acceleration(velocity, onground); + private Force force = new Force(acceleration); + private Mass mass = new Mass(acceleration); + + public void gravity(double y) { + this.force.gravity(y); + this.time.gravity(y); + } + + public void moveX(double x) { + this.move.moveX(x); + } + + public void moveY(double y) { + this.move.moveY(y); + } + + public void setMass(double x) { + this.mass.setValue(x); + } + + public Pair getAcceleration() { + return acceleration.getValue(); + } + + public Pair getMove() { + return move.getValue(); + } + + public double getMass() { + return mass.getValue(); + } + + public boolean getClear() { + return clear.getClear(); + } + + public boolean getGround() { + return ground.getValue(); + } + + public Pair getForce() { + return force.getValue(); + } + + public Pair getVelocity() { + return velocity.getValue(); + } + + public Pair getPosition() { + return position.getValue(); + } + + public boolean getOnground() { + return onground.getOnground(); + } + + public double getTime() { + return time.getValue(); + } + + public boolean getGameover() { + return gameover.getGameover(); + } +} \ No newline at end of file diff --git a/src/main/java/entity/Mass.java b/src/main/java/entity/Mass.java new file mode 100644 index 0000000..cb2bc08 --- /dev/null +++ b/src/main/java/entity/Mass.java @@ -0,0 +1,19 @@ +package entity; + +public class Mass { + private Acceleration acceleration; + private double value; + + public Mass(Acceleration acceleration) { + this.acceleration = acceleration; + } + + public void setValue(double x) { + this.value = x; + acceleration.updateByMass(value); + } + + public double getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/entity/Move.java b/src/main/java/entity/Move.java new file mode 100644 index 0000000..4eb80f0 --- /dev/null +++ b/src/main/java/entity/Move.java @@ -0,0 +1,23 @@ +package entity; + +public class Move { + private Velocity velocity; + private Pair value; + + public Move(Velocity velocity) { + this.velocity = velocity; + } + + public void moveX(double x) { + this.value = new Pair(x, this.value.getSecond()); + velocity.updateByMove(value); + } + + public void moveY(double y) { + this.value = new Pair(this.value.getFirst(), y); + } + + public Pair getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/entity/Onground.java b/src/main/java/entity/Onground.java new file mode 100644 index 0000000..3dff7b1 --- /dev/null +++ b/src/main/java/entity/Onground.java @@ -0,0 +1,14 @@ +package entity; + +public class Onground { + private Ground ground; + private Position position; + + public Onground(Ground ground, Position position) { + this.ground = ground; + this.position = position; + } + + public boolean getOnground() { + return ((this.ground.getValue() == true) && (this.position.getValue().getSecond() <= 0.0)); } +} \ No newline at end of file diff --git a/src/main/java/entity/Pair.java b/src/main/java/entity/Pair.java new file mode 100644 index 0000000..46b8a22 --- /dev/null +++ b/src/main/java/entity/Pair.java @@ -0,0 +1,19 @@ +package entity; + +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/entity/Position.java b/src/main/java/entity/Position.java new file mode 100644 index 0000000..dfff747 --- /dev/null +++ b/src/main/java/entity/Position.java @@ -0,0 +1,24 @@ +package entity; + +public class Position { + private Ground ground; + private Pair value; + + 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 Pair((this.value.getFirst() + (0.01 * velocity.getFirst())), (this.value.getSecond() + (0.01 * velocity.getSecond()))); + } + value = temp_l3; + } + + public Position(Ground ground) { + this.ground = ground; + } + + public Pair getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/entity/Time.java b/src/main/java/entity/Time.java new file mode 100644 index 0000000..4765f75 --- /dev/null +++ b/src/main/java/entity/Time.java @@ -0,0 +1,13 @@ +package entity; + +public class Time { + private double value; + + public void gravity(double y) { + this.value = (this.value + 0.01); + } + + public double getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/entity/Velocity.java b/src/main/java/entity/Velocity.java new file mode 100644 index 0000000..98130b8 --- /dev/null +++ b/src/main/java/entity/Velocity.java @@ -0,0 +1,43 @@ +package entity; + + +public class Velocity { + private Pair moveValue; + private Pair accelerationValue; + private Position position; + private Onground onground; + private Pair value; + + public void updateByMove(Pair move) { + this.moveValue = move; + Pair temp_l2; + if ((this.onground.getOnground() && (move.getSecond() >= 0.0))) { + temp_l2 = move; + } else { + temp_l2 = this.value; + } + value = temp_l2; + position.updateByVelocity(value); + } + + public void updateByAcceleration(Pair acceleration) { + this.accelerationValue = acceleration; + 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 Pair((this.value.getFirst() + (0.01 * acceleration.getFirst())), (this.value.getSecond() + (0.01 * acceleration.getSecond()))); + } + value = temp_l5; + position.updateByVelocity(value); + } + + public Velocity(Position position, Onground onground) { + this.position = position; + this.onground = onground; + } + + public Pair getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/resources/Acceleration.java b/src/main/java/resources/Acceleration.java deleted file mode 100644 index c31e238..0000000 --- a/src/main/java/resources/Acceleration.java +++ /dev/null @@ -1,42 +0,0 @@ -package resources; - -public class Acceleration { - private double massValue; - private Pair forceValue; - private Velocity velocity; - private Onground onground; - private Pair value; - - public void updateByMass(double mass) { - this.massValue = mass; - Pair temp_l0; - if (this.onground.getOnground()) { - temp_l0 = new Pair((forceValue.getFirst() / mass), 0.0); - } else { - temp_l0 = new Pair((forceValue.getFirst() / mass), (forceValue.getSecond() / mass)); - } - value = temp_l0; - velocity.updateByAcceleration(value); - } - - public void updateByForce(Pair force) { - this.forceValue = force; - Pair temp_l1; - if (this.onground.getOnground()) { - temp_l1 = new Pair((force.getFirst() / massValue), 0.0); - } else { - temp_l1 = new Pair((force.getFirst() / massValue), (force.getSecond() / massValue)); - } - value = temp_l1; - velocity.updateByAcceleration(value); - } - - public Acceleration(Velocity velocity, Onground onground) { - this.velocity = velocity; - this.onground = onground; - } - - 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 deleted file mode 100644 index 2325d12..0000000 --- a/src/main/java/resources/Clear.java +++ /dev/null @@ -1,19 +0,0 @@ -package resources; - -public class Clear { - private Position position; - - public Clear(Position position) { - this.position = position; - } - - public boolean getClear() { - boolean temp_l4; - if ((this.position.getValue().getFirst() > 100.0)) { - temp_l4 = true; - } else { - temp_l4 = false; - } - return temp_l4; - } -} \ No newline at end of file diff --git a/src/main/java/resources/Force.java b/src/main/java/resources/Force.java deleted file mode 100644 index 2e5f763..0000000 --- a/src/main/java/resources/Force.java +++ /dev/null @@ -1,19 +0,0 @@ -package resources; - -public class Force { - private Acceleration acceleration; - private Pair value; - - public Force(Acceleration acceleration) { - this.acceleration = acceleration; - } - - public void gravity(double y) { - this.value = new Pair(0.0, y); - acceleration.updateByForce(value); - } - - 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 deleted file mode 100644 index 2bdcac7..0000000 --- a/src/main/java/resources/Gameover.java +++ /dev/null @@ -1,19 +0,0 @@ -package resources; - -public class Gameover { - private Position position; - - public Gameover(Position position) { - this.position = position; - } - - public boolean getGameover() { - boolean temp_l6; - if ((this.position.getValue().getSecond() < -(1.0))) { - temp_l6 = true; - } else { - temp_l6 = false; - } - return temp_l6; - } -} \ No newline at end of file diff --git a/src/main/java/resources/Ground.java b/src/main/java/resources/Ground.java deleted file mode 100644 index 2df0f2f..0000000 --- a/src/main/java/resources/Ground.java +++ /dev/null @@ -1,9 +0,0 @@ -package resources; - -public class Ground { - private boolean value; - - public boolean getValue() { - return value; - } -} \ No newline at end of file diff --git a/src/main/java/resources/JumpGame.java b/src/main/java/resources/JumpGame.java deleted file mode 100644 index c655bb4..0000000 --- a/src/main/java/resources/JumpGame.java +++ /dev/null @@ -1,76 +0,0 @@ -package resources; - -public class JumpGame { - private Time time = new Time(); - private Ground ground = new Ground(); - private Position position = new Position(ground); - private Gameover gameover = new Gameover(position); - private Onground onground = new Onground(ground, position); - private Velocity velocity = new Velocity(position, onground); - private Clear clear = new Clear(position); - private Move move = new Move(velocity); - private Acceleration acceleration = new Acceleration(velocity, onground); - private Force force = new Force(acceleration); - private Mass mass = new Mass(acceleration); - - public void gravity(double y) { - this.force.gravity(y); - this.time.gravity(y); - } - - public void moveX(double x) { - this.move.moveX(x); - } - - public void moveY(double y) { - this.move.moveY(y); - } - - public void setMass(double x) { - this.mass.setValue(x); - } - - public Pair getAcceleration() { - return acceleration.getValue(); - } - - public Pair getMove() { - return move.getValue(); - } - - public double getMass() { - return mass.getValue(); - } - - public boolean getClear() { - return clear.getClear(); - } - - public boolean getGround() { - return ground.getValue(); - } - - public Pair getForce() { - return force.getValue(); - } - - public Pair getVelocity() { - return velocity.getValue(); - } - - public Pair getPosition() { - return position.getValue(); - } - - public boolean getOnground() { - return onground.getOnground(); - } - - public double getTime() { - return time.getValue(); - } - - public boolean getGameover() { - return gameover.getGameover(); - } -} \ No newline at end of file diff --git a/src/main/java/resources/Mass.java b/src/main/java/resources/Mass.java deleted file mode 100644 index c0acc82..0000000 --- a/src/main/java/resources/Mass.java +++ /dev/null @@ -1,19 +0,0 @@ -package resources; - -public class Mass { - private Acceleration acceleration; - private double value; - - public Mass(Acceleration acceleration) { - this.acceleration = acceleration; - } - - public void setValue(double x) { - this.value = x; - acceleration.updateByMass(value); - } - - public double getValue() { - return value; - } -} \ No newline at end of file diff --git a/src/main/java/resources/Move.java b/src/main/java/resources/Move.java deleted file mode 100644 index f258d53..0000000 --- a/src/main/java/resources/Move.java +++ /dev/null @@ -1,23 +0,0 @@ -package resources; - -public class Move { - private Velocity velocity; - private Pair value; - - public Move(Velocity velocity) { - this.velocity = velocity; - } - - public void moveX(double x) { - this.value = new Pair(x, this.value.getSecond()); - velocity.updateByMove(value); - } - - public void moveY(double y) { - this.value = new Pair(this.value.getFirst(), y); - } - - 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 deleted file mode 100644 index 5e60ef5..0000000 --- a/src/main/java/resources/Onground.java +++ /dev/null @@ -1,14 +0,0 @@ -package resources; - -public class Onground { - private Ground ground; - private Position position; - - public Onground(Ground ground, Position position) { - this.ground = ground; - this.position = position; - } - - public boolean getOnground() { - return ((this.ground.getValue() == true) && (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 deleted file mode 100644 index 29d3dbe..0000000 --- a/src/main/java/resources/Pair.java +++ /dev/null @@ -1,19 +0,0 @@ -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 deleted file mode 100644 index e79f7a9..0000000 --- a/src/main/java/resources/Position.java +++ /dev/null @@ -1,24 +0,0 @@ -package resources; - -public class Position { - private Ground ground; - private Pair value; - - 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 Pair((this.value.getFirst() + (0.01 * velocity.getFirst())), (this.value.getSecond() + (0.01 * velocity.getSecond()))); - } - value = temp_l3; - } - - public Position(Ground ground) { - this.ground = ground; - } - - public Pair getValue() { - return value; - } -} \ No newline at end of file diff --git a/src/main/java/resources/Time.java b/src/main/java/resources/Time.java deleted file mode 100644 index 3ba6de2..0000000 --- a/src/main/java/resources/Time.java +++ /dev/null @@ -1,13 +0,0 @@ -package resources; - -public class Time { - private double value; - - public void gravity(double y) { - this.value = (this.value + 0.01); - } - - public double getValue() { - return value; - } -} \ No newline at end of file diff --git a/src/main/java/resources/Velocity.java b/src/main/java/resources/Velocity.java deleted file mode 100644 index 3fa9068..0000000 --- a/src/main/java/resources/Velocity.java +++ /dev/null @@ -1,43 +0,0 @@ -package resources; - - -public class Velocity { - private Pair moveValue; - private Pair accelerationValue; - private Position position; - private Onground onground; - private Pair value; - - public void updateByMove(Pair move) { - this.moveValue = move; - Pair temp_l2; - if ((this.onground.getOnground() && (move.getSecond() >= 0.0))) { - temp_l2 = move; - } else { - temp_l2 = this.value; - } - value = temp_l2; - position.updateByVelocity(value); - } - - public void updateByAcceleration(Pair acceleration) { - this.accelerationValue = acceleration; - 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 Pair((this.value.getFirst() + (0.01 * acceleration.getFirst())), (this.value.getSecond() + (0.01 * acceleration.getSecond()))); - } - value = temp_l5; - position.updateByVelocity(value); - } - - public Velocity(Position position, Onground onground) { - this.position = position; - this.onground = onground; - } - - public Pair getValue() { - return value; - } -} \ No newline at end of file