Implemented proper map size handling in Display

This commit is contained in:
Bokros Bálint 2016-05-14 02:51:10 +02:00 committed by Kjistóf
parent df3bb34969
commit 4f11f60b50
2 changed files with 9 additions and 3 deletions

View File

@ -15,7 +15,7 @@ public class Display extends JPanel{
private List<Drawer> visuals;
private Clip clip;
private Dimension dimension = new Dimension(64*5, 64*5); //TODO make this dependent on dungeon size
private Dimension dimension;
public Display() {
visuals = new ArrayList<>();
@ -27,8 +27,6 @@ public class Display extends JPanel{
}
public void drawVisuals() throws IOException {
setPreferredSize(dimension);
setMinimumSize(dimension);
for(Drawer visual : visuals)
visual.draw();
repaint();
@ -67,6 +65,12 @@ public class Display extends JPanel{
}
}
public void setMapSize(int width, int height) {
dimension = new Dimension(width * 64, height * 64);
setPreferredSize(dimension);
setMinimumSize(dimension);
}
public Dimension getDimension() {
return dimension;
}

View File

@ -70,6 +70,8 @@ public class Game {
jaffa = new Player("Jaffa", players.get("jaffa"), Direction.getRandom());
replicator = new PlayerBase("Replicator", players.get("replicator"), Direction.getRandom());
display.setMapSize(dungeon.getMapWidth(), dungeon.getMapHeight());
display.addVisual(new PlayerDrawer(oneill));
display.addVisual(new PlayerDrawer(jaffa));
display.addVisual(new PlayerBaseDrawer(replicator));