Newer
Older
JumpingGame / src / main / java / views / PlayerRenderer.java
k-fujii on 16 Nov 2021 1 KB 地面を仮描画しました.
package views;

import entities.*;
import models.IModel;
import models.PlayerModel;

//---------------------------------------------------------------
//
public class PlayerRenderer implements IView {
    private Sprite sprite;

    //---------------------------------------------------------------
    //---------------------------------------------------------------
    public PlayerRenderer(String path) {
        this.sprite = new Sprite(path);
        this.sprite.setScaleValue(1);
    }

    //---------------------------------------------------------------
    //---------------------------------------------------------------
    // PlayerModelから座標を取得して描画する
    public void display(IModel model) {

        // Modelがキャスト可能か判定
        if (model instanceof PlayerModel) {
            PlayerModel playerModel = (PlayerModel) model;
            sprite.setPositionValue(playerModel.getPosition().getValue());
        }

        sprite.draw();
    }

    //---------------------------------------------------------------
    // テクスチャの開放
    public void delete() {
        sprite.delete();
    }
    //---------------------------------------------------------------
}