diff --git a/src/main/java/resources/Acceleration.java b/src/main/java/resources/Acceleration.java new file mode 100644 index 0000000..f7d33d4 --- /dev/null +++ b/src/main/java/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