Contol Windwo Update. Velocity Change implemented. FONT and some other Var and method needs to be implemented in the GUI class not in Menu Window

Update Generation in Game Windoms title.
This commit is contained in:
Noah
2021-11-30 10:18:51 +01:00
parent 81594ae84c
commit 319ca9e306
3 changed files with 23 additions and 4 deletions
+8 -3
View File
@@ -2,7 +2,6 @@ package game;
import gui.GUI;
import java.util.ArrayList;
import java.util.concurrent.ThreadLocalRandom;
public class Control {
@@ -139,7 +138,7 @@ public class Control {
public void nextGen() {
gen++;
// System.out.println("Generation:" + gen);
System.out.println("Generation:" + gen);
for (int x = 0; x < xSize; x++) {
for (int y = 0; y < ySize; y++) {
@@ -164,7 +163,7 @@ public class Control {
cells[x][y] = newcells[x][y];
}
}
gui.updateGameWindowTitle(gen);
}
// public void checkN(Boolean[][] arr, Boolean[][] futureGen, int columns, int rows) {
@@ -196,6 +195,7 @@ public class Control {
public boolean[][] nextGenBackup() {
gen++;
// System.out.println("Generation:" + gen);
for (int x = 0; x < xSize; x++) {
@@ -227,6 +227,7 @@ public class Control {
}
}
return cells;
}
@@ -351,6 +352,10 @@ public class Control {
nextGen();
}
}
public int getGeneration(){
return gen;
}
}
+8
View File
@@ -143,6 +143,14 @@ public class GUI {
control.multipleGenSkip(generations);
}
public int getGeneration(){
return control.getGeneration();
}
public void updateGameWindowTitle(int gen){
gameWindow.updateTitle(gen);
}
//TODO: Delet this Methods. Those are shit.
public void setVisibility(boolean value){
controlWindow.setVisibility(value);
+7 -1
View File
@@ -14,6 +14,8 @@ public class GameWindow {
private final int cellCountX;
private final int cellCountY;
private String title;
private int width, height;
private final float ratio;
@@ -23,8 +25,9 @@ public class GameWindow {
this.cellCountX = cellCountX;
this.cellCountY = cellCountY;
this.title = title;
gameWindow = new JFrame(title);
gameWindow = new JFrame(title + " Generation: " + gui.getGeneration());
gameWindow.getContentPane().setPreferredSize(new Dimension(width + (2 * offset), height + (2 * offset)));
gameWindow.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
@@ -157,6 +160,9 @@ public class GameWindow {
public Point getPos(){
return gameWindow.getLocation();
}
public void updateTitle(int gen){
gameWindow.setTitle(title + " Generation: " + gen);
}
}