Browse Source

resize font to correct size

Kajetan Johannes Hammerle 4 years ago
parent
commit
dfc5bdb4ee
2 changed files with 21 additions and 2 deletions
  1. 20 0
      src/pathgame/BiggerFontWindowView.java
  2. 1 2
      src/pathgame/Main.java

+ 20 - 0
src/pathgame/BiggerFontWindowView.java

@@ -0,0 +1,20 @@
+package pathgame;
+
+import me.hammerle.snuviengine.api.WindowView;
+
+public class BiggerFontWindowView implements WindowView {
+
+    @Override
+    public int getScale(int width, int height) {
+        int scale = 1;
+        while(width / (scale + 1) >= 400 && height / (scale + 1) >= 300) {
+            scale++;
+        }
+        return scale;
+    }
+
+    @Override
+    public int getFontScale(int width, int height) {
+        return getScale(width, height) * 2;
+    }
+}

+ 1 - 2
src/pathgame/Main.java

@@ -1,11 +1,10 @@
 package pathgame;
 
-import me.hammerle.snuviengine.api.ResizingWindowView;
 import me.hammerle.snuviengine.api.Window;
 
 public class Main {
     public static void main(String[] args) {
-        Window window = new Window(50_000_000, new ResizingWindowView(400, 300));
+        Window window = new Window(50_000_000, new BiggerFontWindowView());
         window.initialize("Path Game", 1024, 768);
         PathGame game = new PathGame();
         window.open(game);