Newer
Older
JumpingGame / src / main / java / entities / Position.java
package entities;

import java.util.*;

//---------------------------------------------------------------
//
public class Position {
    private Ground ground;
    private Pair<Double> value = new Pair<>(0d, 0d);

    //---------------------------------------------------------------
    //---------------------------------------------------------------
    //
    public void updateByVelocity(Pair<Double> velocity) {
        Pair<Double> 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;
    }

    //---------------------------------------------------------------
    //---------------------------------------------------------------
    // getter
    public Pair<Double> getValue() {
        return value;
    }
}