package views; import entities.Pair; import entities.Sprite; import models.IModel; //--------------------------------------------------------------- // タイルの描画 public class TileRenderer implements IView { private Sprite sprite; private double moveSpeed = -1; //--------------------------------------------------------------- //--------------------------------------------------------------- // public TileRenderer(String path, Pair<Double> initPosition) { this.sprite = new Sprite(path); this.sprite.setScaleValue(1); this.sprite.setPositionValue(initPosition); } //--------------------------------------------------------------- public TileRenderer(String path, Pair<Double> initPosition, double scale) { 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) { } //--------------------------------------------------------------- // 描画 @Override public void display() { sprite.draw(); move(); } //--------------------------------------------------------------- // テクスチャの開放 @Override public void delete() { sprite.delete(); } //--------------------------------------------------------------- //--------------------------------------------------------------- // 移動 private void move() { double x = sprite.getPositionValue().getFirst() + moveSpeed; double y = sprite.getPositionValue().getSecond(); sprite.setPositionValue(new Pair<>(x, y)); } //--------------------------------------------------------------- }