package views; import entities.Pair; import models.IModel; import models.JumpGameModel; import java.lang.reflect.Parameter; //--------------------------------------------------------------- // タイルの描画 public class TileRenderer implements IView { private Sprite sprite; private Pair<Double> initPositionValue; //--------------------------------------------------------------- //--------------------------------------------------------------- // public TileRenderer(String path, Pair<Double> initPosition) { this.initPositionValue = initPosition; this.sprite = new Sprite(path); this.sprite.setScaleValue(1); this.sprite.setPositionValue(initPosition); } //--------------------------------------------------------------- public TileRenderer(String path, Pair<Double> initPosition, double scale) { this.initPositionValue = initPosition; this.sprite = new Sprite(path); this.sprite.setScaleValue(scale); this.sprite.setPositionValue(initPosition); } //--------------------------------------------------------------- //--------------------------------------------------------------- // getter public double getScaleValue() { return this.sprite.getScaleValue(); } //--------------------------------------------------------------- //--------------------------------------------------------------- // setter public void setScaleValue(double scaleValue) { this.sprite.setScaleValue(scaleValue); } //--------------------------------------------------------------- //--------------------------------------------------------------- // @Override public void update(IModel model) { JumpGameModel jumpGameModel = (JumpGameModel) model; Double x = this.initPositionValue.getFirst() - (jumpGameModel.getPosition().getFirst() * 64); Double y = this.sprite.getPositionValue().getSecond(); this.sprite.setPositionValue(new Pair<>(x, y)); } //--------------------------------------------------------------- // 描画 @Override public void display() { sprite.draw(); } //--------------------------------------------------------------- // テクスチャの開放 @Override public void delete() { sprite.delete(); } }