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:
@@ -2,7 +2,6 @@ package game;
|
|||||||
|
|
||||||
import gui.GUI;
|
import gui.GUI;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
public class Control {
|
public class Control {
|
||||||
@@ -139,7 +138,7 @@ public class Control {
|
|||||||
public void nextGen() {
|
public void nextGen() {
|
||||||
|
|
||||||
gen++;
|
gen++;
|
||||||
// System.out.println("Generation:" + gen);
|
System.out.println("Generation:" + gen);
|
||||||
|
|
||||||
for (int x = 0; x < xSize; x++) {
|
for (int x = 0; x < xSize; x++) {
|
||||||
for (int y = 0; y < ySize; y++) {
|
for (int y = 0; y < ySize; y++) {
|
||||||
@@ -164,7 +163,7 @@ public class Control {
|
|||||||
cells[x][y] = newcells[x][y];
|
cells[x][y] = newcells[x][y];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
gui.updateGameWindowTitle(gen);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void checkN(Boolean[][] arr, Boolean[][] futureGen, int columns, int rows) {
|
// public void checkN(Boolean[][] arr, Boolean[][] futureGen, int columns, int rows) {
|
||||||
@@ -196,6 +195,7 @@ public class Control {
|
|||||||
public boolean[][] nextGenBackup() {
|
public boolean[][] nextGenBackup() {
|
||||||
|
|
||||||
gen++;
|
gen++;
|
||||||
|
|
||||||
// System.out.println("Generation:" + gen);
|
// System.out.println("Generation:" + gen);
|
||||||
|
|
||||||
for (int x = 0; x < xSize; x++) {
|
for (int x = 0; x < xSize; x++) {
|
||||||
@@ -227,6 +227,7 @@ public class Control {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return cells;
|
return cells;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,6 +352,10 @@ public class Control {
|
|||||||
nextGen();
|
nextGen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getGeneration(){
|
||||||
|
return gen;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -143,6 +143,14 @@ public class GUI {
|
|||||||
control.multipleGenSkip(generations);
|
control.multipleGenSkip(generations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getGeneration(){
|
||||||
|
return control.getGeneration();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateGameWindowTitle(int gen){
|
||||||
|
gameWindow.updateTitle(gen);
|
||||||
|
}
|
||||||
|
|
||||||
//TODO: Delet this Methods. Those are shit.
|
//TODO: Delet this Methods. Those are shit.
|
||||||
public void setVisibility(boolean value){
|
public void setVisibility(boolean value){
|
||||||
controlWindow.setVisibility(value);
|
controlWindow.setVisibility(value);
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ public class GameWindow {
|
|||||||
private final int cellCountX;
|
private final int cellCountX;
|
||||||
private final int cellCountY;
|
private final int cellCountY;
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
|
||||||
private int width, height;
|
private int width, height;
|
||||||
private final float ratio;
|
private final float ratio;
|
||||||
|
|
||||||
@@ -23,8 +25,9 @@ public class GameWindow {
|
|||||||
this.cellCountX = cellCountX;
|
this.cellCountX = cellCountX;
|
||||||
this.cellCountY = cellCountY;
|
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.getContentPane().setPreferredSize(new Dimension(width + (2 * offset), height + (2 * offset)));
|
||||||
gameWindow.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
gameWindow.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||||
@@ -157,6 +160,9 @@ public class GameWindow {
|
|||||||
public Point getPos(){
|
public Point getPos(){
|
||||||
return gameWindow.getLocation();
|
return gameWindow.getLocation();
|
||||||
}
|
}
|
||||||
|
public void updateTitle(int gen){
|
||||||
|
gameWindow.setTitle(title + " Generation: " + gen);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user