Newer
Older
JumpingGame / src / main / java / models / PlayerModel.java
package models;

import entities.*;

//---------------------------------------------------------------
//
public class PlayerModel implements IModel {
    //---------------------------------------------------------------
    private Acceleration acceleration;
    private Force force;
    private Mass mass;
    private Move move;
    private Position position;
    private Velocity velocity;
    private Onground onground;

    //---------------------------------------------------------------
    private double jumpPower = 32;

    //---------------------------------------------------------------
    //
    public PlayerModel(Ground ground) {

        position = new Position(new Pair<>(640d, 480d), ground);
        onground = new Onground(ground, position);
        velocity = new Velocity(position, onground);
        acceleration = new Acceleration(velocity, onground);
        force = new Force(acceleration);
        mass = new Mass(acceleration);
        move = new Move(velocity);
    }

    //---------------------------------------------------------------
    //---------------------------------------------------------------
    // getter
    public Position getPosition() {
        return position;
    }

    //---------------------------------------------------------------
    //
    public void jump() {
        this.move.moveY(jumpPower);
    }

    //---------------------------------------------------------------
    //
    public void updateGravity(double gravity) {
        this.force.gravity(gravity);
    }
}