diff --git a/README.md b/README.md index 734b005..e2ab130 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -JumpGame +resources.JumpGame =============== diff --git a/src/Acceleration.java b/src/Acceleration.java deleted file mode 100644 index c60c686..0000000 --- a/src/Acceleration.java +++ /dev/null @@ -1,41 +0,0 @@ -import java.util.*; - -public class Acceleration { - private double massValue; - private Map.Entry forceValue; - private Velocity velocity; - private Onground onground; - private Map.Entry value; - - public void updateByMass(double mass) { - this.massValue = mass; - Map.Entry temp_l0; - if (this.onground.getOnground()) { - temp_l0 = new AbstractMap.SimpleEntry<>((forceValue.getKey() / mass), 0.0); - } else { - temp_l0 = new AbstractMap.SimpleEntry<>((forceValue.getKey() / mass), (forceValue.getValue() / mass)); - } - value = temp_l0; - velocity.updateByAcceleration(value); - } - - public void updateByForce(Map.Entry force) { - this.forceValue = force; - Map.Entry temp_l1; - if (this.onground.getOnground()) { - temp_l1 = new AbstractMap.SimpleEntry<>((force.getKey() / massValue), 0.0); - } else { - temp_l1 = new AbstractMap.SimpleEntry<>((force.getKey() / massValue), (force.getValue() / massValue)); - } - value = temp_l1; - velocity.updateByAcceleration(value); - } - - public Acceleration(Velocity velocity, Onground onground) { - this.onground = onground; - } - - public Map.Entry getValue() { - return value; - } -} \ No newline at end of file diff --git a/src/Clear.java b/src/Clear.java deleted file mode 100644 index fc4d855..0000000 --- a/src/Clear.java +++ /dev/null @@ -1,17 +0,0 @@ -public class Clear { - private Position position; - - public Clear(Position position) { - this.position = position; - } - - public boolean getClear() { - boolean temp_l4; - if ((this.position.getValue().getKey() > 100.0)) { - temp_l4 = true; - } else { - temp_l4 = false; - } - return temp_l4; - } -} \ No newline at end of file diff --git a/src/Force.java b/src/Force.java deleted file mode 100644 index 68fb3f7..0000000 --- a/src/Force.java +++ /dev/null @@ -1,19 +0,0 @@ -import java.util.*; - -public class Force { - private Acceleration acceleration; - private Map.Entry value; - - public Force(Acceleration acceleration) { - this.acceleration = acceleration; - } - - public void gravity(double y) { - this.value = new AbstractMap.SimpleEntry<>(0.0, y); - acceleration.updateByForce(value); - } - - public Map.Entry getValue() { - return value; - } -} \ No newline at end of file diff --git a/src/Gameover.java b/src/Gameover.java deleted file mode 100644 index 15d7af5..0000000 --- a/src/Gameover.java +++ /dev/null @@ -1,17 +0,0 @@ -public class Gameover { - private Position position; - - public Gameover(Position position) { - this.position = position; - } - - public boolean getGameover() { - boolean temp_l6; - if ((this.position.getValue().getValue() < -(1.0))) { - temp_l6 = true; - } else { - temp_l6 = false; - } - return temp_l6; - } -} \ No newline at end of file diff --git a/src/Ground.java b/src/Ground.java deleted file mode 100644 index 7b3b112..0000000 --- a/src/Ground.java +++ /dev/null @@ -1,7 +0,0 @@ -public class Ground { - private boolean value; - - public boolean getValue() { - return value; - } -} \ No newline at end of file diff --git a/src/JumpGame.java b/src/JumpGame.java deleted file mode 100644 index ae0aca6..0000000 --- a/src/JumpGame.java +++ /dev/null @@ -1,76 +0,0 @@ -import java.util.*; - -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 Map.Entry getAcceleration() { - return acceleration.getValue(); - } - - public Map.Entry getMove() { - return move.getValue(); - } - - public double getMass() { - return mass.getValue(); - } - - public boolean getClear() { - return clear.getClear(); - } - - public boolean getGround() { - return ground.getValue(); - } - - public Map.Entry getForce() { - return force.getValue(); - } - - public Map.Entry getVelocity() { - return velocity.getValue(); - } - - public Map.Entry 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/Mass.java b/src/Mass.java deleted file mode 100644 index 96cc156..0000000 --- a/src/Mass.java +++ /dev/null @@ -1,17 +0,0 @@ -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/Move.java b/src/Move.java deleted file mode 100644 index bbd2013..0000000 --- a/src/Move.java +++ /dev/null @@ -1,23 +0,0 @@ -import java.util.*; - -public class Move { - private Velocity velocity; - private Map.Entry value; - - public Move(Velocity velocity) { - this.velocity = velocity; - } - - public void moveX(double x) { - this.value = new AbstractMap.SimpleEntry<>(x, this.value.getValue()); - velocity.updateByMove(value); - } - - public void moveY(double y) { - this.value = new AbstractMap.SimpleEntry<>(this.value.getKey(), y); - } - - public Map.Entry getValue() { - return value; - } -} \ No newline at end of file diff --git a/src/Onground.java b/src/Onground.java deleted file mode 100644 index 751041f..0000000 --- a/src/Onground.java +++ /dev/null @@ -1,13 +0,0 @@ -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().getValue() <= 0.0)); - } -} \ No newline at end of file diff --git a/src/Position.java b/src/Position.java deleted file mode 100644 index dc8cbc5..0000000 --- a/src/Position.java +++ /dev/null @@ -1,24 +0,0 @@ -import java.util.*; - -public class Position { - private Ground ground; - private Map.Entry 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); - } else { - temp_l3 = new AbstractMap.SimpleEntry<>((this.value.getKey() + (0.01 * velocity.getKey())), (this.value.getValue() + (0.01 * velocity.getValue()))); - } - value = temp_l3; - } - - public Position(Ground ground) { - this.ground = ground; - } - - public Map.Entry getValue() { - return value; - } -} \ No newline at end of file diff --git a/src/Time.java b/src/Time.java deleted file mode 100644 index 9a4e7fd..0000000 --- a/src/Time.java +++ /dev/null @@ -1,11 +0,0 @@ -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/Velocity.java b/src/Velocity.java deleted file mode 100644 index 860b2af..0000000 --- a/src/Velocity.java +++ /dev/null @@ -1,42 +0,0 @@ -import java.util.*; - -public class Velocity { - private Map.Entry moveValue; - private Map.Entry accelerationValue; - private Position position; - private Onground onground; - private Map.Entry value; - - public void updateByMove(Map.Entry move) { - this.moveValue = move; - Map.Entry temp_l2; - if ((this.onground.getOnground() && (move.getValue() >= 0.0))) { - temp_l2 = move; - } else { - temp_l2 = this.value; - } - value = temp_l2; - position.updateByVelocity(value); - } - - public void updateByAcceleration(Map.Entry 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); - } else { - temp_l5 = new AbstractMap.SimpleEntry<>((this.value.getKey() + (0.01 * acceleration.getKey())), (this.value.getValue() + (0.01 * acceleration.getValue()))); - } - value = temp_l5; - position.updateByVelocity(value); - } - - public Velocity(Position position, Onground onground) { - this.position = position; - this.onground = onground; - } - - public Map.Entry getValue() { - return value; - } -} \ No newline at end of file diff --git a/src/resources/Acceleration.java b/src/resources/Acceleration.java new file mode 100644 index 0000000..f7d33d4 --- /dev/null +++ b/src/resources/Acceleration.java @@ -0,0 +1,42 @@ +package resources; + +public class Acceleration { + private double massValue; + private Vector2 forceValue; + private Velocity velocity; + private Onground onground; + private Vector2 value; + + public void updateByMass(double mass) { + this.massValue = mass; + Vector2 temp_l0; + if (this.onground.getOnground()) { + temp_l0 = new Vector2((forceValue.getX() / mass), 0.0); + } else { + temp_l0 = new Vector2((forceValue.getX() / mass), (forceValue.getY() / mass)); + } + value = temp_l0; + velocity.updateByAcceleration(value); + } + + public void updateByForce(Vector2 force) { + this.forceValue = force; + Vector2 temp_l1; + if (this.onground.getOnground()) { + temp_l1 = new Vector2((force.getX() / massValue), 0.0); + } else { + 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 Vector2 getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/resources/Clear.java b/src/resources/Clear.java new file mode 100644 index 0000000..8076814 --- /dev/null +++ b/src/resources/Clear.java @@ -0,0 +1,19 @@ +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().getX() > 100.0)) { + temp_l4 = true; + } else { + temp_l4 = false; + } + return temp_l4; + } +} \ No newline at end of file diff --git a/src/resources/Force.java b/src/resources/Force.java new file mode 100644 index 0000000..5ee523e --- /dev/null +++ b/src/resources/Force.java @@ -0,0 +1,19 @@ +package resources; + +public class Force { + private Acceleration acceleration; + private Vector2 value; + + public Force(Acceleration acceleration) { + this.acceleration = acceleration; + } + + public void gravity(double y) { + this.value = new Vector2(0.0, y); + acceleration.updateByForce(value); + } + + public Vector2 getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/resources/Gameover.java b/src/resources/Gameover.java new file mode 100644 index 0000000..9f95b01 --- /dev/null +++ b/src/resources/Gameover.java @@ -0,0 +1,19 @@ +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().getY() < -(1.0))) { + temp_l6 = true; + } else { + temp_l6 = false; + } + return temp_l6; + } +} \ No newline at end of file diff --git a/src/resources/Ground.java b/src/resources/Ground.java new file mode 100644 index 0000000..2df0f2f --- /dev/null +++ b/src/resources/Ground.java @@ -0,0 +1,9 @@ +package resources; + +public class Ground { + private boolean value; + + public boolean getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/resources/JumpGame.java b/src/resources/JumpGame.java new file mode 100644 index 0000000..6689e0e --- /dev/null +++ b/src/resources/JumpGame.java @@ -0,0 +1,76 @@ +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 Vector2 getAcceleration() { + return acceleration.getValue(); + } + + public Vector2 getMove() { + return move.getValue(); + } + + public double getMass() { + return mass.getValue(); + } + + public boolean getClear() { + return clear.getClear(); + } + + public boolean getGround() { + return ground.getValue(); + } + + public Vector2 getForce() { + return force.getValue(); + } + + public Vector2 getVelocity() { + return velocity.getValue(); + } + + public Vector2 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/resources/Mass.java b/src/resources/Mass.java new file mode 100644 index 0000000..c0acc82 --- /dev/null +++ b/src/resources/Mass.java @@ -0,0 +1,19 @@ +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/resources/Move.java b/src/resources/Move.java new file mode 100644 index 0000000..20be320 --- /dev/null +++ b/src/resources/Move.java @@ -0,0 +1,23 @@ +package resources; + +public class Move { + private Velocity velocity; + private Vector2 value; + + public Move(Velocity velocity) { + this.velocity = velocity; + } + + public void moveX(double x) { + this.value = new Vector2(x, this.value.getY()); + velocity.updateByMove(value); + } + + public void moveY(double y) { + this.value = new Vector2(this.value.getX(), y); + } + + public Vector2 getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/resources/Onground.java b/src/resources/Onground.java new file mode 100644 index 0000000..de8ece5 --- /dev/null +++ b/src/resources/Onground.java @@ -0,0 +1,14 @@ +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().getY() <= 0.0)); } +} \ No newline at end of file diff --git a/src/resources/Position.java b/src/resources/Position.java new file mode 100644 index 0000000..d890660 --- /dev/null +++ b/src/resources/Position.java @@ -0,0 +1,24 @@ +package resources; + +public class Position { + private Ground ground; + private Vector2 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); + } else { + temp_l3 = new Vector2((this.value.getX() + (0.01 * velocity.getX())), (this.value.getY() + (0.01 * velocity.getY()))); + } + value = temp_l3; + } + + public Position(Ground ground) { + this.ground = ground; + } + + public Vector2 getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/resources/Time.java b/src/resources/Time.java new file mode 100644 index 0000000..3ba6de2 --- /dev/null +++ b/src/resources/Time.java @@ -0,0 +1,13 @@ +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/resources/Vector2.java b/src/resources/Vector2.java new file mode 100644 index 0000000..8b97696 --- /dev/null +++ b/src/resources/Vector2.java @@ -0,0 +1,19 @@ +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/resources/Velocity.java b/src/resources/Velocity.java new file mode 100644 index 0000000..fcae09b --- /dev/null +++ b/src/resources/Velocity.java @@ -0,0 +1,42 @@ +package resources; + +public class Velocity { + private Vector2 moveValue; + private Vector2 accelerationValue; + private Position position; + private Onground onground; + private Vector2 value; + + public void updateByMove(Vector2 move) { + this.moveValue = move; + Vector2 temp_l2; + if ((this.onground.getOnground() && (move.getY() >= 0.0))) { + temp_l2 = move; + } else { + temp_l2 = this.value; + } + value = temp_l2; + position.updateByVelocity(value); + } + + public void updateByAcceleration(Vector2 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); + } else { + temp_l5 = new Vector2((this.value.getX() + (0.01 * acceleration.getX())), (this.value.getY() + (0.01 * acceleration.getY()))); + } + value = temp_l5; + position.updateByVelocity(value); + } + + public Velocity(Position position, Onground onground) { + this.position = position; + this.onground = onground; + } + + public Vector2 getValue() { + return value; + } +} \ No newline at end of file