diff options
Diffstat (limited to '')
-rw-r--r-- | src/subconscious/graphics/MapScene.java | 14 | ||||
-rw-r--r-- | src/subconscious/graphics/Scene.java | 2 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/subconscious/graphics/MapScene.java b/src/subconscious/graphics/MapScene.java index e17a933..149d03d 100644 --- a/src/subconscious/graphics/MapScene.java +++ b/src/subconscious/graphics/MapScene.java @@ -9,6 +9,7 @@ import java.awt.Canvas; import java.awt.Point; import java.awt.Graphics2D; import java.awt.BasicStroke; +import java.awt.Dimension; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; @@ -223,6 +224,19 @@ public abstract class MapScene extends Scene { } @Override + public synchronized void updateCanvasSize(Dimension newSize) { + super.updateCanvasSize(newSize); + + if (this.canvasSize.width < this.canvasSize.height) { + this.shorterCanvasLenght = this.canvasSize.width; + } else { + this.shorterCanvasLenght = this.canvasSize.height; + } + + this.tileSize = this.shorterCanvasLenght / 10; + } + + @Override public void keyPressed(KeyEvent e) { super.keyPressed(e); diff --git a/src/subconscious/graphics/Scene.java b/src/subconscious/graphics/Scene.java index cfbdc87..a6ac018 100644 --- a/src/subconscious/graphics/Scene.java +++ b/src/subconscious/graphics/Scene.java @@ -251,7 +251,7 @@ public abstract class Scene extends JPanel // WARNING: does not always work // TODO: why doesn't this always work? public synchronized void updateCanvasSize() { - this.canvasSize = this.getParent().getParent().getSize(); + this.updateCanvasSize(this.getParent().getSize()); } // this one always works |