Newer
Older
JumpingGame / src / main / java / JumpGame.java
import entities.*;
import models.IModel;
import models.ModelType;
import models.PlayerModel;
import views.IView;
import views.PlayerRenderer;

import java.util.ArrayList;

public class JumpGame {
    //---------------------------------------------------------------
//    private Time time = new Time();
    private Ground ground = new Ground();
//    private Position position = new Position(ground);
//    private Gameover gameover = new Gameover(position);
//    private Onground onground = new Onground(ground, position);
//    private Velocity velocity = new Velocity(position, onground);
//    private Clear clear = new Clear(position);
//    private Move move = new Move(velocity);
//    private Acceleration acceleration = new Acceleration(velocity, onground);
//    private Force force = new Force(acceleration);
//    private Mass mass = new Mass(acceleration);

    //---------------------------------------------------------------
    // new
    private int i = 0;
    private ArrayList<IView> views = new ArrayList<>();
    private ArrayList<IModel> models = new ArrayList<>();

    //---------------------------------------------------------------
    //---------------------------------------------------------------
    //
    public void gravity(double y) {
//            this.force.gravity(y);
//           this.time.gravity(y);
        PlayerModel playerModel = (PlayerModel) models.get(ModelType.PlayerModel);
        playerModel.updateGravity(y);
    }

    //---------------------------------------------------------------
    // 初期化
    public void init() {

        // model
        models.add(new PlayerModel(ground));

        // view
        views.add(new PlayerRenderer("resources/chicken.png", 0.5));

    }

    //---------------------------------------------------------------
    // 更新処理
    public void update() {

        // Viewの更新
        for (IModel model : models) {
            for (IView view : views) view.display(model);
        }

        // Modelの更新
        //
        // Space キーのインプット
        //
        // マイフレーム更新

        gravity(0.01); //重力
    }

    //---------------------------------------------------------------
    // デストラクタのような処理
    public void delete() {
        for (IView view : views) view.delete();
    }

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

}