Calculating Windows Size

This commit is contained in:
Noah
2021-10-04 12:30:24 +02:00
parent 9cb505d4da
commit 03bab94c0f
2 changed files with 10 additions and 7 deletions
+8 -6
View File
@@ -249,13 +249,15 @@ public class Control {
private void calcSize(){ private void calcSize(){
float c = 800; float ratio = (float) (xSize) / (float) (ySize);
if (xSize > ySize){
width = 800;
height = (int) (width / ratio);
} else {
height = 800;
width = (int) (height * ratio);
}
width = Math.round(xSize * (c / xSize));
height = Math.round(ySize * (c / ySize));
System.out.println(xSize + " " + width);
System.out.println(ySize + " " + height);
} }
+2 -1
View File
@@ -1,13 +1,14 @@
package main; package main;
import game.Control;
import game.Control;
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
Control control = new Control(); Control control = new Control();
control.start(); control.start();
} }