package views; import entities.GLConfigVariable; import entities.Pair; import entities.TileType; import models.IModel; import java.util.ArrayList; //--------------------------------------------------------------- // タイル生成 public class TileMapRenderer implements IView { private double offsetY = 256d; private TileRenderer newTile = new TileRenderer("resources/tile.png",null,2); private ArrayList<TileRenderer> tiles = new ArrayList<>(); //--------------------------------------------------------------- //--------------------------------------------------------------- public TileMapRenderer() { initTiles(); } //--------------------------------------------------------------- //--------------------------------------------------------------- // public void display(IModel model) { for (TileRenderer tile : tiles) tile.display(model); } //--------------------------------------------------------------- // public void delete() { for (TileRenderer tile : tiles) tile.delete(); } //-------------------------------------------------------------- // タイルをフラグに応じて生成する private void createTile(TileType tileType) { switch (tileType) { case CLOSE: newTile = new TileRenderer("resources/tile.png", new Pair<>((double) GLConfigVariable.WIDTH, 0d), 2); break; case OPEN: newTile = new TileRenderer("resources/hole.png", new Pair<>((double) GLConfigVariable.WIDTH, 0d),2); break; } tiles.add(newTile); } //--------------------------------------------------------------- // 初期タイル作成 private void initTiles() { for (double x = 0; x <= GLConfigVariable.WIDTH; x += 32 * newTile.getScaleValue()) { newTile = new TileRenderer("resources/tile.png", new Pair<>(x, offsetY)); newTile.setScaleValue(2); tiles.add(newTile); } } //--------------------------------------------------------------- }