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 List<Drawer> visuals;
|
||||||
private Clip clip;
|
private Clip clip;
|
||||||
|
|
||||||
private Dimension dimension = new Dimension(64*5, 64*5); //TODO make this dependent on dungeon size
|
private Dimension dimension;
|
||||||
|
|
||||||
public Display() {
|
public Display() {
|
||||||
visuals = new ArrayList<>();
|
visuals = new ArrayList<>();
|
||||||
@ -27,8 +27,6 @@ public class Display extends JPanel{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void drawVisuals() throws IOException {
|
public void drawVisuals() throws IOException {
|
||||||
setPreferredSize(dimension);
|
|
||||||
setMinimumSize(dimension);
|
|
||||||
for(Drawer visual : visuals)
|
for(Drawer visual : visuals)
|
||||||
visual.draw();
|
visual.draw();
|
||||||
repaint();
|
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() {
|
public Dimension getDimension() {
|
||||||
return dimension;
|
return dimension;
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,8 @@ public class Game {
|
|||||||
jaffa = new Player("Jaffa", players.get("jaffa"), Direction.getRandom());
|
jaffa = new Player("Jaffa", players.get("jaffa"), Direction.getRandom());
|
||||||
replicator = new PlayerBase("Replicator", players.get("replicator"), 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(oneill));
|
||||||
display.addVisual(new PlayerDrawer(jaffa));
|
display.addVisual(new PlayerDrawer(jaffa));
|
||||||
display.addVisual(new PlayerBaseDrawer(replicator));
|
display.addVisual(new PlayerBaseDrawer(replicator));
|
||||||
|
Loading…
Reference in New Issue
Block a user