Nice stuff is Done. Some GUI and Code Structure.

This commit is contained in:
Noah
2021-10-05 22:35:14 +02:00
parent 808083a770
commit 546e5cbfc0
8 changed files with 139 additions and 45 deletions
+23 -5
View File
@@ -19,15 +19,31 @@ public class GameWindow {
private boolean mouseLeft = false, mouseRight = false;
public GameWindow(String title, GUI gui, int cellCountX, int cellCountY, int width, int height) {
public GameWindow(String title, GUI gui, int cellCountX, int cellCountY, int width, int height, int offset) {
this.cellCountX = cellCountX;
this.cellCountY = cellCountY;
gameWindow = new JFrame(title);
gameWindow.getContentPane().setPreferredSize(new Dimension(width, height));
gameWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
gameWindow.getContentPane().setPreferredSize(new Dimension(width + (2 * offset), height + (2 * offset)));
gameWindow.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
ImageIcon imageIcon = new ImageIcon("src/files/PNG/Icon.png");
gameWindow.setIconImage(imageIcon.getImage());
gameWindow.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
super.windowClosing(e);
if (gui.getControlWindow() != null){
gui.getControlWindow().dispose();
}
gameWindow.dispose();
gui.getMenuWindow().setVisibility(true);
}
});
gameWindow.addKeyListener(new KeyListener() {
@Override
@@ -109,12 +125,15 @@ public class GameWindow {
}
});
gameWindow.setResizable(false);
ratio = (float) (cellCountY) / (float) (cellCountX);
draw = new Draw(this.cellCountX, this.cellCountY, width, height, ratio);
draw = new Draw(this.cellCountX, this.cellCountY, width, height, ratio, offset);
draw.setBounds(0, 0, width, height);
draw.setVisible(true);
gameWindow.add(draw);
@@ -138,5 +157,4 @@ public class GameWindow {
}
}