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

import entities.*;
import entities.modelExtentions.Flags;

import javax.swing.plaf.synth.SynthTextAreaUI;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

//---------------------------------------------------------------
//
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 = 32;

    //---------------------------------------------------------------
    private Flags flags;
    private boolean tileType = true;

    //---------------------------------------------------------------
    //---------------------------------------------------------------
    //
    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);
        flags = new Flags();
    }

    //---------------------------------------------------------------
    //---------------------------------------------------------------
    // getter
    public Flags getFlags() {
        return flags;
    }

    public Position getPosition() {
        return position;
    }

    public Velocity getVelocity() {
        return velocity;
    }

    public Ground getGround() {
        return ground;
    }

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

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

    //---------------------------------------------------------------
    //
    public void updateGroundFlag() {
        int x = position.getValue().getFirst().intValue();

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

        System.out.print("x: " + x + "/");
        System.out.println("Ground: " + ground.getValue());
    }

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

    }


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