From a659fc5cfe73938731cc0b431f1c42a2fa0ed02d Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Mon, 19 Nov 2018 10:58:47 +0100 Subject: Update GameWindow and remove parent frame dependency on Scene --- src/BattleScene.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/BattleScene.java') diff --git a/src/BattleScene.java b/src/BattleScene.java index 1e4b633..df691ea 100644 --- a/src/BattleScene.java +++ b/src/BattleScene.java @@ -43,8 +43,8 @@ public class BattleScene extends MapScene { private int realX = 0; private int realY = 0; - public BattleScene(JFrame frame) { - super(frame); + public BattleScene() { + super(); // TODO: this should be handled in MapScene MapLoader mapLoader = new MapLoader("../testmap.json"); @@ -91,26 +91,27 @@ public class BattleScene extends MapScene { //draw panels g.setColor(Palette.WHITE_T); - g.fillRect(this.WIDTH-100*this.guiSize, this.HEIGHT-100*this.guiSize, + g.fillRect(this.canvasSize.width-100*this.guiSize, this.canvasSize.height-100*this.guiSize, 100*this.guiSize, 100*this.guiSize); - g.fillRect(0, this.HEIGHT-100*this.guiSize, 150*this.guiSize, 100*this.guiSize); + g.fillRect(0, this.canvasSize.height-100*this.guiSize, 150*this.guiSize, 100*this.guiSize); g.setColor(Palette.BLACK); g.setFont(g.getFont().deriveFont(12.0F*this.guiSize)); Tile tile = null; + try{ tile = this.map.getTile(this.previousX, this.previousY); switch (tile.getType()) { case CLEAR: break; case GRASS: - g.drawString("Grass", this.WIDTH-90*this.guiSize, this.HEIGHT-80*this.guiSize); + g.drawString("Grass", this.canvasSize.width-90*this.guiSize, this.canvasSize.height-80*this.guiSize); break; case WATER: - g.drawString("Water", this.WIDTH-90*this.guiSize, this.HEIGHT-80*this.guiSize); + g.drawString("Water", this.canvasSize.width-90*this.guiSize, this.canvasSize.height-80*this.guiSize); break; case MOUNTAIN: - g.drawString("Mountain", this.WIDTH-90*this.guiSize, this.HEIGHT-80*this.guiSize); + g.drawString("Mountain", this.canvasSize.width-90*this.guiSize, this.canvasSize.height-80*this.guiSize); break; } @@ -118,7 +119,7 @@ public class BattleScene extends MapScene { if (this.actorClicked && this.lastActor != null) { g.setColor(Palette.WHITE_T); g.fillRect(0, 0, 100*this.guiSize, 150*this.guiSize); - g.fillRect(this.WIDTH-100*this.guiSize, 0, 100*this.guiSize, 100*this.guiSize); + g.fillRect(this.canvasSize.width-100*this.guiSize, 0, 100*this.guiSize, 100*this.guiSize); g.setColor(Palette.BLACK); g.drawString(this.lastActor.getName(), 5*this.guiSize, 15*this.guiSize); @@ -135,7 +136,7 @@ public class BattleScene extends MapScene { } else if (this.actorClicked) { g.setColor(Palette.WHITE_T); g.fillRect(0, 0, 100*this.guiSize, 150*this.guiSize); - g.fillRect(this.WIDTH-100*this.guiSize, 0, 100*this.guiSize, 100*this.guiSize); + g.fillRect(this.canvasSize.width-100*this.guiSize, 0, 100*this.guiSize, 100*this.guiSize); g.setColor(Palette.BLACK); g.drawString("None left", 5*this.guiSize, 15*this.guiSize); -- cgit v1.2.1