import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.util.ArrayList; public class WorldScene extends Scene { private ArrayList actors = new ArrayList(); private Map map; private int tileSize; public WorldScene(Dimension gridSize, int tileSize) { this.tileSize = tileSize; map = new Map(gridSize); Player player = new Player("pipo", gridSize); this.actors.add(player); } @Override public void render(Graphics g) { Graphics2D g2d = (Graphics2D) g; for (Tile tile : this.map.grid) { switch (tile.type) { case GRASS: g2d.setColor(Palette.GREEN); break; case WATER: g2d.setColor(Palette.BLUE); break; } g2d.fillRect( this.tileSize * tile.x, this.tileSize * tile.y, this.tileSize, this.tileSize ); } for (Actor actor : this.actors) { switch (actor.type) { case PLAYER: g2d.setColor(Palette.ORANGE); break; case ENEMY: g2d.setColor(Palette.RED); break; } int gap = this.tileSize/10; g2d.fillRect( (this.tileSize * actor.x) + gap, (this.tileSize * actor.y) + gap, this.tileSize-gap, this.tileSize-gap ); } } }