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

import java.util.ArrayList;

public class JumpGame {
    //---------------------------------------------------------------
//    private Time time = new Time();
//    private Gameover gameover = new Gameover(position);
//    private Clear clear = new Clear(position);

    //---------------------------------------------------------------
    // 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 GroundModel());

        GroundModel groundModel = (GroundModel) models.get(ModelType.GroundModel);
        models.add(new PlayerModel(groundModel.getGround()));

        // view
        views.add(new TileRenderer("resources/tile.png", 1));
        views.add(new PlayerRenderer("resources/chicken.png", 1));
    }

    //---------------------------------------------------------------
    // 更新処理
    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();
    }

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

}