Newer
Older
JumpingGame / src / main / java / JumpGame.java
import models.IModel;
import models.JumpGameModel;
import views.IView;
import views.PlayerRenderer;
import views.TileMapRenderer;

import java.util.ArrayList;

public class JumpGame {
    //---------------------------------------------------------------

    //---------------------------------------------------------------
    // new
    private ArrayList<IView> views = new ArrayList<>();
    private IModel model = new JumpGameModel();

    //---------------------------------------------------------------
    //---------------------------------------------------------------
    //
    public void gravity(double y) {
//           this.time.gravity(y);
        JumpGameModel jumpGameModel = (JumpGameModel) model;
        jumpGameModel.updateGravity(y);
    }

    //---------------------------------------------------------------
    // 初期化
    public void init() {
        // view
        views.add(new TileMapRenderer());
        views.add(new PlayerRenderer("resources/chicken.png"));
    }

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

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

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

        gravity(-256); //重力
    }

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

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

}