Implemented proper map size handling in Display
This commit is contained in:
parent
df3bb34969
commit
4f11f60b50
@ -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;
|
||||
}
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user