diff --git a/cicaprojekt/Display.java b/cicaprojekt/Display.java index bd56ec5..1ad09f0 100644 --- a/cicaprojekt/Display.java +++ b/cicaprojekt/Display.java @@ -15,7 +15,7 @@ public class Display extends JPanel{ private List 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; } diff --git a/cicaprojekt/Game.java b/cicaprojekt/Game.java index 29d6fa7..07eb9c9 100644 --- a/cicaprojekt/Game.java +++ b/cicaprojekt/Game.java @@ -69,6 +69,8 @@ public class Game { oneill = new Player("O'Neill", players.get("oneill"), Direction.getRandom()); 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));