Replace to vector #4

Merged k-fujii merged 2 commits into nitta-lab:develop from nitta-lab:replace_to_vector on 11 Nov 2021
Showing 26 changed files
View
2
■■■
README.md
JumpGame
resources.JumpGame
===============
View
41
src/Acceleration.java 100644 → 0
import java.util.*;
 
public class Acceleration {
private double massValue;
private Map.Entry<Double, Double> forceValue;
private Velocity velocity;
private Onground onground;
private Map.Entry<Double, Double> value;
 
public void updateByMass(double mass) {
this.massValue = mass;
Map.Entry<Double, Double> 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<Double, Double> force) {
this.forceValue = force;
Map.Entry<Double, Double> 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<Double, Double> getValue() {
return value;
}
}
View
17
src/Clear.java 100644 → 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;
}
}
View
19
src/Force.java 100644 → 0
import java.util.*;
 
public class Force {
private Acceleration acceleration;
private Map.Entry<Double, Double> 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<Double, Double> getValue() {
return value;
}
}
View
17
src/Gameover.java 100644 → 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;
}
}
View
7
src/Ground.java 100644 → 0
public class Ground {
private boolean value;
 
public boolean getValue() {
return value;
}
}
View
76
src/JumpGame.java 100644 → 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<Double, Double> getAcceleration() {
return acceleration.getValue();
}
 
public Map.Entry<Double, Double> 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<Double, Double> getForce() {
return force.getValue();
}
 
public Map.Entry<Double, Double> getVelocity() {
return velocity.getValue();
}
 
public Map.Entry<Double, Double> getPosition() {
return position.getValue();
}
 
public boolean getOnground() {
return onground.getOnground();
}
 
public double getTime() {
return time.getValue();
}
 
public boolean getGameover() {
return gameover.getGameover();
}
}
View
17
src/Mass.java 100644 → 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;
}
}
View
23
src/Move.java 100644 → 0
import java.util.*;
 
public class Move {
private Velocity velocity;
private Map.Entry<Double, Double> 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<Double, Double> getValue() {
return value;
}
}
View
13
src/Onground.java 100644 → 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));
}
}
View
24
src/Position.java 100644 → 0
import java.util.*;
 
public class Position {
private Ground ground;
private Map.Entry<Double, Double> value;
 
public void updateByVelocity(Map.Entry<Double, Double> velocity) {
Map.Entry<Double, Double> 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<Double, Double> getValue() {
return value;
}
}
View
11
src/Time.java 100644 → 0
public class Time {
private double value;
 
public void gravity(double y) {
this.value = (this.value + 0.01);
}
 
public double getValue() {
return value;
}
}
View
42
src/Velocity.java 100644 → 0
import java.util.*;
 
public class Velocity {
private Map.Entry<Double, Double> moveValue;
private Map.Entry<Double, Double> accelerationValue;
private Position position;
private Onground onground;
private Map.Entry<Double, Double> value;
 
public void updateByMove(Map.Entry<Double, Double> move) {
this.moveValue = move;
Map.Entry<Double, Double> 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<Double, Double> acceleration) {
this.accelerationValue = acceleration;
Map.Entry<Double, Double> 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<Double, Double> getValue() {
return value;
}
}
View
42
src/resources/Acceleration.java 0 → 100644
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;
}
}
View
19
src/resources/Clear.java 0 → 100644
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;
}
}
View
19
src/resources/Force.java 0 → 100644
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;
}
}
View
19
src/resources/Gameover.java 0 → 100644
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;
}
}
View
9
src/resources/Ground.java 0 → 100644
package resources;
 
public class Ground {
private boolean value;
 
public boolean getValue() {
return value;
}
}
View
76
src/resources/JumpGame.java 0 → 100644
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();
}
}
View
19
src/resources/Mass.java 0 → 100644
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;
}
}
View
23
src/resources/Move.java 0 → 100644
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;
}
}
View
14
src/resources/Onground.java 0 → 100644
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)); }
}
View
24
src/resources/Position.java 0 → 100644
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;
}
}
View
13
src/resources/Time.java 0 → 100644
package resources;
 
public class Time {
private double value;
 
public void gravity(double y) {
this.value = (this.value + 0.01);
}
 
public double getValue() {
return value;
}
}
View
20
src/resources/Vector2.java 0 → 100644
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;
}
}
View
42
src/resources/Velocity.java 0 → 100644
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;
}
}