Newer
Older
JumpingGame / src / main / java / JumpGame.java
k-fujii on 16 Nov 2021 2 KB 地面を仮描画しました.
import models.GroundModel;
import models.IModel;
import entities.ModelType;
import models.PlayerModel;
import views.IView;
import views.PlayerRenderer;
import views.TileMapRenderer;
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.PLAYER_MODEL);
        playerModel.updateGravity(y);
    }

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

        // model
        models.add(new GroundModel());

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

        // view
        views.add(new TileMapRenderer());
        views.add(new PlayerRenderer("resources/chicken.png"));
    }

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

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

}