Newer
Older
JumpingGame / src / main / java / models / JumpGameModel.java
k-fujii on 7 Dec 2021 4 KB FlagsをStageにリネーム
package models;

import entities.*;
import entities.modelExtentions.Stage;

//---------------------------------------------------------------
//
public class JumpGameModel implements IModel {

    private Acceleration acceleration;
    private Force force;
    private Mass mass;
    private Move move;
    private Position position;
    private Velocity velocity;
    private Onground onground;

    //---------------------------------------------------------------
    private Time time;
    private Gameover gameover;
    private Clear clear;

    //---------------------------------------------------------------
    private Ground ground;

    //---------------------------------------------------------------
    private double jumpPower = 256;

    //---------------------------------------------------------------
    private Stage stage;

    //---------------------------------------------------------------
    //---------------------------------------------------------------
    //
    public JumpGameModel() {
        ground = new Ground();
        position = new Position(ground);
        onground = new Onground(ground, position);
        velocity = new Velocity(new Pair<>(1d, 0d), position, onground);
        acceleration = new Acceleration(velocity, onground);
        force = new Force(acceleration);
        mass = new Mass(acceleration);
        move = new Move(velocity);
        time = new Time();
        gameover = new Gameover(position);
        clear = new Clear(position);
        stage = new Stage();
    }

    //---------------------------------------------------------------
    //---------------------------------------------------------------
    // getter
    public Stage getStage() {
        return stage;
    }

    public Pair<Double> getPosition() {
        return position.getValue();
    }

    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 Pair<Double> getAcceleration() {
        return acceleration.getValue();
    }

    public Pair<Double> getMove() {
        return move.getValue();
    }

    public double getMass() {
        return mass.getValue();
    }

    public boolean getClear() {
        return clear.getClear();
    }

    public boolean getGround() {
        return ground.getValue();
    }

    public Pair<Double> getForce() {
        return force.getValue();
    }

    public Pair<Double> getVelocity() {
        return velocity.getValue();
    }

    public boolean getOnground() {
        return onground.getOnground();
    }

    public double getTime() {
        return time.getValue();
    }

    public boolean getGameover() {
        return gameover.getGameover();
    }

    //---------------------------------------------------------------
    //---------------------------------------------------------------
    // ジャンプ
    public void jump() {
        this.move.moveY(jumpPower);
    }

    //---------------------------------------------------------------
    // マイフレーム更新処理
    public void updateGravity(double gravity) {
        this.time.gravity(gravity);
        this.force.gravity(gravity);
//        System.out.println("swapWindow Gravity");
    }

    //---------------------------------------------------------------
    // 地面のフラグ更新
    public void updateGroundFlag() {
        double x = position.getValue().getFirst();

        if (stage.isOpenFlag(x)) ground.openHole();
        if (stage.isCloseFlag(x)) ground.closeHole();

        System.out.print("x: " + x + "/");
        System.out.println("Ground: " + ground.getValue() + "/");
//        System.out.print("Clear: " + clear.getClear() + "/");
//        System.out.println("GameOver: " + gameover.getGameover());

    }

    //---------------------------------------------------------------
    //

    //---------------------------------------------------------------
    //
    private void init() {

    }


    //---------------------------------------------------------------
}