diff --git a/Game Of Life/GameOfLifeTest/sample/GameOfLifeTest.java b/Game Of Life/GameOfLifeTest/sample/GameOfLifeTest.java new file mode 100644 index 0000000..d14c5fe --- /dev/null +++ b/Game Of Life/GameOfLifeTest/sample/GameOfLifeTest.java @@ -0,0 +1,35 @@ +package sample; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Created by jorge on 04.04.2017. + */ +/* +public class GameOfLifeTest { + GameOfLife gol = new GameOfLife(); + + @Test + public void testNextGeneration() throws Exception { + byte[][] board = { + { 1, 1, 1, 0}, + { 1, 1, 0, 0}, + { 0, 0, 1, 0}, + { 0, 0, 0, 0}, + }; + + + + GameOfLife gol = new GameOfLife(); + Controller.setBoard(board); + gol.nextGeneration(); + org.junit.Assert.assertEquals(gol.toString(), "1110110000100000"); + System.out.println("Test OK"); + + } + + } + +*/ \ No newline at end of file diff --git a/Game Of Life/out/production/Game Of Life/sample/Controller.class b/Game Of Life/out/production/Game Of Life/sample/Controller.class new file mode 100644 index 0000000..6491d7f Binary files /dev/null and b/Game Of Life/out/production/Game Of Life/sample/Controller.class differ diff --git a/Game Of Life/out/production/Game Of Life/sample/ConwaysRules.class b/Game Of Life/out/production/Game Of Life/sample/ConwaysRules.class new file mode 100644 index 0000000..c7a0fab Binary files /dev/null and b/Game Of Life/out/production/Game Of Life/sample/ConwaysRules.class differ diff --git a/Game Of Life/out/production/Game Of Life/sample/FileHandler.class b/Game Of Life/out/production/Game Of Life/sample/FileHandler.class new file mode 100644 index 0000000..ad1c394 Binary files /dev/null and b/Game Of Life/out/production/Game Of Life/sample/FileHandler.class differ diff --git a/Game Of Life/out/production/Game Of Life/sample/GameOfLife$1.class b/Game Of Life/out/production/Game Of Life/sample/GameOfLife$1.class new file mode 100644 index 0000000..0f15b95 Binary files /dev/null and b/Game Of Life/out/production/Game Of Life/sample/GameOfLife$1.class differ diff --git a/Game Of Life/out/production/Game Of Life/sample/GameOfLife.class b/Game Of Life/out/production/Game Of Life/sample/GameOfLife.class new file mode 100644 index 0000000..67a76af Binary files /dev/null and b/Game Of Life/out/production/Game Of Life/sample/GameOfLife.class differ diff --git a/Game Of Life/out/production/Game Of Life/sample/Main.class b/Game Of Life/out/production/Game Of Life/sample/Main.class new file mode 100644 index 0000000..bc98fed Binary files /dev/null and b/Game Of Life/out/production/Game Of Life/sample/Main.class differ diff --git a/Game Of Life/out/production/Game Of Life/sample/Rules.class b/Game Of Life/out/production/Game Of Life/sample/Rules.class new file mode 100644 index 0000000..2de72f7 Binary files /dev/null and b/Game Of Life/out/production/Game Of Life/sample/Rules.class differ diff --git a/Game Of Life/out/production/Game Of Life/sample/golfx.fxml b/Game Of Life/out/production/Game Of Life/sample/golfx.fxml new file mode 100644 index 0000000..f0f28d0 --- /dev/null +++ b/Game Of Life/out/production/Game Of Life/sample/golfx.fxml @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Game Of Life/src/sample/Controller.java b/Game Of Life/src/sample/Controller.java index 44776ea..21eb3de 100644 --- a/Game Of Life/src/sample/Controller.java +++ b/Game Of Life/src/sample/Controller.java @@ -1,228 +1,228 @@ -package sample; - -import javafx.event.ActionEvent; -import javafx.fxml.FXML; -import javafx.fxml.Initializable; -import javafx.scene.canvas.Canvas; -import javafx.scene.canvas.GraphicsContext; -import javafx.scene.control.Alert; -import javafx.scene.control.ColorPicker; -import javafx.scene.control.Slider; -import javafx.scene.control.TextField; -import javafx.scene.input.MouseEvent; -import javafx.scene.paint.Color; -import java.net.URL; -import java.util.Random; -import java.util.ResourceBundle; - -public class Controller extends GameOfLife implements Initializable{ - - @FXML private Canvas canvas; - @FXML private ColorPicker colorPicker; - @FXML private Slider speedModifier; - @FXML private Slider gameZoom; - @FXML private TextField inputY; - @FXML private TextField inputX; - private double cellSize = 10; - private Color dynamicColor; - - @Override - public void initialize(URL location, ResourceBundle resources) { - //gameZoom.setMin(1); - //gameZoom.setMax(10); - - byte[][] testBrett = new byte [65][80]; - - /*byte[][] testBrett = { - { 1, 1, 1, 0, 1, 0, 0, 0, 0, 0}, - { 1, 1, 0, 0, 1, 0, 0, 1, 1, 0}, - { 0, 0, 0, 0, 1, 0, 0, 1, 0, 0}, - { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - { 1, 1, 1, 0, 0, 0, 0, 1, 1, 0}, - { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0}, - { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, - }; - - */ - - setCanvas(canvas); - setBoard(testBrett, this); - animation(); - draw(); - grid(); - - } - - public void setCanvas(Canvas canvas) { - this.canvas = canvas; - } - - public void draw() { - - if(getBoard() != null) { - canvas.setHeight(getBoard().length * cellSize); - canvas.setWidth(getBoard()[0].length * cellSize); - - if (canvas != null) { - GraphicsContext gc = canvas.getGraphicsContext2D(); - gc.setFill(dynamicColor); - gc.clearRect(0, 0, canvas.getWidth(), canvas.getHeight()); - - for (int i = 0; i < getBoard().length; i++) { - for (int j = 0; j < getBoard()[0].length; j++) { - if (getBoard()[i][j] == 1) { - gc.fillRect(j * cellSize, i * cellSize, cellSize, cellSize); - } - } - } - } - } - grid(); - } - - public void grid() { - GraphicsContext gc = canvas.getGraphicsContext2D(); - - for(double row=0;row { - byte x = (byte) (e.getY() / cellSize); - byte y = (byte) (e.getX() / cellSize); - - if(getBoard()[x][y] == 1) { - getBoard()[x][y] = 1; // Beholder 1 da vi ikke ønsker å "fjerne" celler ved drafunksjon. - draw(); - } else { - getBoard()[x][y] = 1; - draw(); - } - } - ); - } - - // tillater bruker å opprette/fjerne celler ved museklikk. - @FXML - public void mouseClick() { - canvas.setOnMouseClicked(e -> { - byte x = (byte) (e.getY() / cellSize); - byte y = (byte) (e.getX() / cellSize); - - if(getBoard()[x][y] == 1) { - getBoard()[x][y] = 0; - draw(); - } else { - getBoard()[x][y] = 1; - draw(); - } - } - ); - } -} - +package sample; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.canvas.Canvas; +import javafx.scene.canvas.GraphicsContext; +import javafx.scene.control.Alert; +import javafx.scene.control.ColorPicker; +import javafx.scene.control.Slider; +import javafx.scene.control.TextField; +import javafx.scene.input.MouseEvent; +import javafx.scene.paint.Color; +import java.net.URL; +import java.util.Random; +import java.util.ResourceBundle; + +public class Controller extends GameOfLife implements Initializable{ + + @FXML private Canvas canvas; + @FXML private ColorPicker colorPicker; + @FXML private Slider speedModifier; + @FXML private Slider gameZoom; + @FXML private TextField inputY; + @FXML private TextField inputX; + private double cellSize = 10; + private Color dynamicColor; + + @Override + public void initialize(URL location, ResourceBundle resources) { + //gameZoom.setMin(1); + //gameZoom.setMax(10); + + byte[][] testBrett = new byte [65][80]; + + /*byte[][] testBrett = { + { 1, 1, 1, 0, 1, 0, 0, 0, 0, 0}, + { 1, 1, 0, 0, 1, 0, 0, 1, 1, 0}, + { 0, 0, 0, 0, 1, 0, 0, 1, 0, 0}, + { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + { 1, 1, 1, 0, 0, 0, 0, 1, 1, 0}, + { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0}, + { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, + }; + + */ + + setCanvas(canvas); + setBoard(testBrett, this); + animation(); + draw(); + grid(); + + } + + public void setCanvas(Canvas canvas) { + this.canvas = canvas; + } + + public void draw() { + + if(getBoard() != null) { + canvas.setHeight(getBoard().length * cellSize); + canvas.setWidth(getBoard()[0].length * cellSize); + + if (canvas != null) { + GraphicsContext gc = canvas.getGraphicsContext2D(); + gc.setFill(dynamicColor); + gc.clearRect(0, 0, canvas.getWidth(), canvas.getHeight()); + + for (int i = 0; i < getBoard().length; i++) { + for (int j = 0; j < getBoard()[0].length; j++) { + if (getBoard()[i][j] == 1) { + gc.fillRect(j * cellSize, i * cellSize, cellSize, cellSize); + } + } + } + } + } + grid(); + } + + public void grid() { + GraphicsContext gc = canvas.getGraphicsContext2D(); + + for(double row=0;row { + byte x = (byte) (e.getY() / cellSize); + byte y = (byte) (e.getX() / cellSize); + + if(getBoard()[x][y] == 1) { + getBoard()[x][y] = 1; // Beholder 1 da vi ikke ønsker å "fjerne" celler ved drafunksjon. + draw(); + } else { + getBoard()[x][y] = 1; + draw(); + } + } + ); + } + + // tillater bruker å opprette/fjerne celler ved museklikk. + @FXML + public void mouseClick() { + canvas.setOnMouseClicked(e -> { + byte x = (byte) (e.getY() / cellSize); + byte y = (byte) (e.getX() / cellSize); + + if(getBoard()[x][y] == 1) { + getBoard()[x][y] = 0; + draw(); + } else { + getBoard()[x][y] = 1; + draw(); + } + } + ); + } +} + diff --git a/Game Of Life/src/sample/ConwaysRules.java b/Game Of Life/src/sample/ConwaysRules.java index a2b2ccf..128821b 100644 --- a/Game Of Life/src/sample/ConwaysRules.java +++ b/Game Of Life/src/sample/ConwaysRules.java @@ -1,37 +1,37 @@ -package sample; - -/** - * Created by Fikre on 07.03.2017. - */ -public class ConwaysRules implements Rules { - - @Override - public int overlever(int lever, int antallNaboer) { - // FØLGE REGLER OG SE OM DEN SKAL LEVE - - //HVIS DET ER NØYAKTIG 3 LEVENDE CELLER RUNDT EN DØD CELLE, BLIR DET TIL EN LEVENDE CELLE - //OVERPRODUKSJON - if (lever == 0 && antallNaboer == 3) { - return 1; - } - - // HVIS CELLER RUNDT ER UNDER 2 LEVENDE, SÅ DØR DEN AV UNDERPOPULASJON - if (lever == 1 && antallNaboer < 2) { - return 0; - } - - //HVIS CELLER RUNDT ER 2 ELLER 3, SÅ LEVER DEN VIDERE - if (lever == 1 && antallNaboer == 2 || antallNaboer == 3) { - return 1; - } - - //HVIS CELLER RUNDT ER FLER ENN 3, DØR DEN AV OVERPOPULASJON - if (lever == 1 && antallNaboer > 3) { - return 0; - } - - return lever; // RETUNER 0 ELLER 1. 1 ER LEVENDE OG 0 ER DØD. - } -} - - +package sample; + +/** + * Created by Fikre on 07.03.2017. + */ +public class ConwaysRules implements Rules { + + @Override + public int overlever(int lever, int antallNaboer) { + // FØLGE REGLER OG SE OM DEN SKAL LEVE + + //HVIS DET ER NØYAKTIG 3 LEVENDE CELLER RUNDT EN DØD CELLE, BLIR DET TIL EN LEVENDE CELLE + //OVERPRODUKSJON + if (lever == 0 && antallNaboer == 3) { + return 1; + } + + // HVIS CELLER RUNDT ER UNDER 2 LEVENDE, SÅ DØR DEN AV UNDERPOPULASJON + if (lever == 1 && antallNaboer < 2) { + return 0; + } + + //HVIS CELLER RUNDT ER 2 ELLER 3, SÅ LEVER DEN VIDERE + if (lever == 1 && antallNaboer == 2 || antallNaboer == 3) { + return 1; + } + + //HVIS CELLER RUNDT ER FLER ENN 3, DØR DEN AV OVERPOPULASJON + if (lever == 1 && antallNaboer > 3) { + return 0; + } + + return lever; // RETUNER 0 ELLER 1. 1 ER LEVENDE OG 0 ER DØD. + } +} + + diff --git a/Game Of Life/src/sample/FileHandler.java b/Game Of Life/src/sample/FileHandler.java index cbe1349..e2aed31 100644 --- a/Game Of Life/src/sample/FileHandler.java +++ b/Game Of Life/src/sample/FileHandler.java @@ -1,128 +1,129 @@ -package sample; - -import javafx.stage.FileChooser; -import javafx.stage.Stage; -import javafx.util.converter.CharacterStringConverter; -import jdk.nashorn.internal.runtime.regexp.joni.encoding.CharacterType; - -import java.io.*; - -public class FileHandler { - - private byte[][] newBoard = null; - - public void openFile() { - - FileChooser fileChooser = new FileChooser(); - fileChooser.setTitle("Open new game"); - - - //Fil-filter: - fileChooser.getExtensionFilters().addAll( - new FileChooser.ExtensionFilter("RLE", "*.rle"), - new FileChooser.ExtensionFilter("Text-files", "*.txt") - ); - File file = fileChooser.showOpenDialog(new Stage()); - - try { - readGameDisk(file); - } catch (IOException e) { - e.printStackTrace(); - } - - } - - public void readGameDisk(File file) throws IOException { - BufferedReader reader = new BufferedReader(new FileReader(file)); // lager objekt som leser. - String line; // oppretter objektet line; - int width = 0; - int height = 0; - - while ((line = reader.readLine()) != null) { //leser linje for linje - - if (line.charAt(0) == 'x') { // Når den leser X. - - String[] splitx = line.split(","); //splitter etter komma - - for (String s : splitx) { // Går gjennom hver splitverdi. - int number = 0; //Begynner på index 0. - int plass = 1; // Siste tallet ganges med 1. Se kode lengre nede hvor plass ganges med 10. Dette for å få heltall til slutt. - for (int i = s.length() - 1; i >= 0; i--) { - if (Character.isDigit(s.charAt(i))) { - number += (s.charAt(i) - 48) * plass; // -48 pga ASCII (char). - plass *= 10; //looper bakover, derfor ganges med 10 (10-tallsystemet), for å få heltall. - } - } - - if (width == 0) { - width = number; - } else if (height == 0) { - height = number; - } else { - newBoard = new byte[height][width]; - - } - } -/* HENTE UT KOORDINATORER */ - - } else if (newBoard != null) { - - String[] splity = line.split("\\$"); - - int roundCount = 0; - - for (String y : splity) { - System.out.println(y); - - //Denne linjen setter telleren. - //int roundCount = 0; - - /* for (int i = y.length(); i >= 0; i++) { - - if (y.charAt(i) == 'o') { // Hvis den treffer på "o" eller "b" eller tall. - System.out.println("1"); - } else if (y.charAt(i) == 'b') { - System.out.println("0"); - } else { - System.out.println("multipliseres med"); - } - - - } -*/ - //roundCount++; - - - } - - - } - } - } - - - // Metode for å returnere det nye brettet som er lastet inn. - public byte[][] getNewBoard () { - return newBoard; - } - - - } - - -//runcount -// tall som kommer etter -// x * tegn som kommer etter - - - - - - - - - - - - - +package sample; + +import javafx.stage.FileChooser; +import javafx.stage.Stage; +import javafx.util.converter.CharacterStringConverter; +import jdk.nashorn.internal.runtime.regexp.joni.encoding.CharacterType; + +import java.io.*; + +public class FileHandler { + + private byte[][] newBoard = null; + + public void openFile() { + + FileChooser fileChooser = new FileChooser(); + fileChooser.setTitle("Open new game"); + + + //Fil-filter: + fileChooser.getExtensionFilters().addAll( + new FileChooser.ExtensionFilter("RLE", "*.rle"), + new FileChooser.ExtensionFilter("Text-files", "*.txt") + ); + File file = fileChooser.showOpenDialog(new Stage()); + + try { + readGameDisk(file); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + public void readGameDisk(File file) throws IOException { + BufferedReader reader = new BufferedReader(new FileReader(file)); // lager objekt som leser. + String line; // oppretter objektet line; + int width = 0; + int height = 0; + + while ((line = reader.readLine()) != null) { //leser linje for linje + + if (line.charAt(0) == 'x') { // Når den leser X. + + String[] splitx = line.split(","); //splitter etter komma + + for (String s : splitx) { // Går gjennom hver splitverdi. + int number = 0; //Begynner på index 0. + int plass = 1; // Siste tallet ganges med 1. Se kode lengre nede hvor plass ganges med 10. Dette for å få heltall til slutt. + for (int i = s.length() - 1; i >= 0; i--) { + if (Character.isDigit(s.charAt(i))) { + number += (s.charAt(i) - 48) * plass; // -48 pga ASCII (char). + plass *= 10; //looper bakover, derfor ganges med 10 (10-tallsystemet), for å få heltall. + } + } + + if (width == 0) { + width = number; + } else if (height == 0) { + height = number; + } else { + newBoard = new byte[height][width]; + + } + } +/* HENTE UT KOORDINATORER */ + + } else if (newBoard != null) { + + String[] splity = line.split("\\$"); + + int roundCount = 0; + + for (String y : splity) { + System.out.println(y); + + //Denne linjen setter telleren. + //int roundCount = 0; + + /* for (int i = y.length(); i >= 0; i++) { + + if (y.charAt(i) == 'o') { // Hvis den treffer på "o" eller "b" eller tall. + System.out.println("1"); + } else if (y.charAt(i) == 'b') { + System.out.println("0"); + } else { + System.out.println("multipliseres med"); + } + + + } +*/ + //roundCount++; + + + } + + + } + } + } + + + // Metode for å returnere det nye brettet som er lastet inn. + public byte[][] getNewBoard () { + return newBoard; + } + + + } + +// Test av branch. + +//runcount +// tall som kommer etter +// x * tegn som kommer etter + + + + + + + + + + + + + diff --git a/Game Of Life/src/sample/GameOfLife.java b/Game Of Life/src/sample/GameOfLife.java index 57f04ec..9da2e06 100644 --- a/Game Of Life/src/sample/GameOfLife.java +++ b/Game Of Life/src/sample/GameOfLife.java @@ -1,103 +1,103 @@ -package sample; - - -import javafx.animation.KeyFrame; -import javafx.animation.Timeline; -import javafx.event.ActionEvent; -import javafx.event.EventHandler; -import javafx.fxml.FXML; -import javafx.util.Duration; -import javafx.animation.Animation; -import javafx.scene.control.Button; - - -public class GameOfLife { - - public Rules RuleType = new ConwaysRules(); - private byte[][] board; - private Timeline timeline = new Timeline(); - private Controller context; - @FXML private Button playButton; - - - // GraphicsContext gc = canvas.getGraphicsContext2D(); Hvis den ligger ute kan den nas av alle metoder men ligger på minne hele tiden, best utenfor eller inni metodene? - - public void setBoard(byte[][] board, Controller context) { - this.board = board; - this.context = context; - } - - public void animation() { - //JAVA ANIMASJON - KeyFrame frame = new KeyFrame(Duration.millis(500), new EventHandler() { - @Override - public void handle(ActionEvent event) { - nextGeneration(); - context.draw(); - } - }); - - timeline.getKeyFrames().add(frame); - timeline.setCycleCount(Timeline.INDEFINITE); - } - - public void startGame() { - //Checks if the animation is running - if (timeline.getStatus() == Animation.Status.RUNNING) { - timeline.stop(); - playButton.setText("Play"); - } else { - timeline.play(); - playButton.setText("Pause"); - } - } - - public void nextGeneration(){ - if(board != null){ - byte[][] nyttBrett = new byte[board.length][board[0].length]; - - for(int y=0; y < board.length; y++){ - for (int x=0; x < board[0].length; x++){ - nyttBrett[y][x] = (byte) RuleType.overlever(board[y][x], countNeighbours(y, x)); - } - } - this.board = nyttBrett; - } - } - - private int countNeighbours(int y, int x) { - - int livingNeighbours = 0; - for (int i = -1; i <= 1; i++) { - for (int k = -1; k <= 1; k++) { - if (k == 0 && i == 0) { // Remove self testing - continue; - } - try { // Catch outside borders - if (board[y + i][x + k] == 1) { // If cell state alive - livingNeighbours++; - } - } catch (ArrayIndexOutOfBoundsException e) {//Outside borders} - } - } - } - return livingNeighbours; - } - - public byte[][] getBoard(){ - return board; - } - - public Timeline getTimeline(){ - return timeline; - } - - public void deleteBoard(){ - if (timeline.getStatus() == Animation.Status.RUNNING) { - timeline.stop(); - playButton.setText("Play"); - } - board = null; - - } -} +package sample; + + +import javafx.animation.KeyFrame; +import javafx.animation.Timeline; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.fxml.FXML; +import javafx.util.Duration; +import javafx.animation.Animation; +import javafx.scene.control.Button; + + +public class GameOfLife { + + public Rules RuleType = new ConwaysRules(); + private byte[][] board; + private Timeline timeline = new Timeline(); + private Controller context; + @FXML private Button playButton; + + + // GraphicsContext gc = canvas.getGraphicsContext2D(); Hvis den ligger ute kan den nas av alle metoder men ligger på minne hele tiden, best utenfor eller inni metodene? + + public void setBoard(byte[][] board, Controller context) { + this.board = board; + this.context = context; + } + + public void animation() { + //JAVA ANIMASJON + KeyFrame frame = new KeyFrame(Duration.millis(500), new EventHandler() { + @Override + public void handle(ActionEvent event) { + nextGeneration(); + context.draw(); + } + }); + + timeline.getKeyFrames().add(frame); + timeline.setCycleCount(Timeline.INDEFINITE); + } + + public void startGame() { + //Checks if the animation is running + if (timeline.getStatus() == Animation.Status.RUNNING) { + timeline.stop(); + playButton.setText("Play"); + } else { + timeline.play(); + playButton.setText("Pause"); + } + } + + public void nextGeneration(){ + if(board != null){ + byte[][] nyttBrett = new byte[board.length][board[0].length]; + + for(int y=0; y < board.length; y++){ + for (int x=0; x < board[0].length; x++){ + nyttBrett[y][x] = (byte) RuleType.overlever(board[y][x], countNeighbours(y, x)); + } + } + this.board = nyttBrett; + } + } + + private int countNeighbours(int y, int x) { + + int livingNeighbours = 0; + for (int i = -1; i <= 1; i++) { + for (int k = -1; k <= 1; k++) { + if (k == 0 && i == 0) { // Remove self testing + continue; + } + try { // Catch outside borders + if (board[y + i][x + k] == 1) { // If cell state alive + livingNeighbours++; + } + } catch (ArrayIndexOutOfBoundsException e) {//Outside borders} + } + } + } + return livingNeighbours; + } + + public byte[][] getBoard(){ + return board; + } + + public Timeline getTimeline(){ + return timeline; + } + + public void deleteBoard(){ + if (timeline.getStatus() == Animation.Status.RUNNING) { + timeline.stop(); + playButton.setText("Play"); + } + board = null; + + } +} diff --git a/Game Of Life/src/sample/Main.java b/Game Of Life/src/sample/Main.java index e8980d2..409e54a 100644 --- a/Game Of Life/src/sample/Main.java +++ b/Game Of Life/src/sample/Main.java @@ -1,23 +1,23 @@ -package sample; - -import javafx.application.Application; -import javafx.fxml.FXMLLoader; -import javafx.scene.Parent; -import javafx.scene.Scene; -import javafx.stage.Stage; - -public class Main extends Application { - - @Override - public void start(Stage primaryStage) throws Exception{ - Parent root = FXMLLoader.load(getClass().getResource("golfx.fxml")); - primaryStage.setTitle("Game Of Life"); - primaryStage.setScene(new Scene(root, 993, 679)); - primaryStage.show(); - } - - - public static void main(String[] args) { - launch(args); - } -} +package sample; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.stage.Stage; + +public class Main extends Application { + + @Override + public void start(Stage primaryStage) throws Exception{ + Parent root = FXMLLoader.load(getClass().getResource("golfx.fxml")); + primaryStage.setTitle("Game Of Life"); + primaryStage.setScene(new Scene(root, 993, 679)); + primaryStage.show(); + } + + + public static void main(String[] args) { + launch(args); + } +} diff --git a/Game Of Life/src/sample/Rules.java b/Game Of Life/src/sample/Rules.java index bf18fe3..b6ad978 100644 --- a/Game Of Life/src/sample/Rules.java +++ b/Game Of Life/src/sample/Rules.java @@ -1,9 +1,9 @@ -package sample; - -/** - * Created by Fikre on 07.03.2017. - */ -public interface Rules { - - public int overlever(int lever, int antallNaboer); -} +package sample; + +/** + * Created by Fikre on 07.03.2017. + */ +public interface Rules { + + public int overlever(int lever, int antallNaboer); +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..ae42948 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# GameOfLife2017 + +Game Of Life via IntelliJ diff --git a/out/production/Game Of Life/sample/Controller.class b/out/production/Game Of Life/sample/Controller.class new file mode 100644 index 0000000..a619285 Binary files /dev/null and b/out/production/Game Of Life/sample/Controller.class differ diff --git a/out/production/Game Of Life/sample/ConwaysRules.class b/out/production/Game Of Life/sample/ConwaysRules.class new file mode 100644 index 0000000..c7a0fab Binary files /dev/null and b/out/production/Game Of Life/sample/ConwaysRules.class differ diff --git a/out/production/Game Of Life/sample/FileHandler.class b/out/production/Game Of Life/sample/FileHandler.class new file mode 100644 index 0000000..dfe5969 Binary files /dev/null and b/out/production/Game Of Life/sample/FileHandler.class differ diff --git a/out/production/Game Of Life/sample/GameOfLife$1.class b/out/production/Game Of Life/sample/GameOfLife$1.class new file mode 100644 index 0000000..8d5ab36 Binary files /dev/null and b/out/production/Game Of Life/sample/GameOfLife$1.class differ diff --git a/out/production/Game Of Life/sample/GameOfLife.class b/out/production/Game Of Life/sample/GameOfLife.class new file mode 100644 index 0000000..f49470d Binary files /dev/null and b/out/production/Game Of Life/sample/GameOfLife.class differ diff --git a/out/production/Game Of Life/sample/Main.class b/out/production/Game Of Life/sample/Main.class new file mode 100644 index 0000000..bc98fed Binary files /dev/null and b/out/production/Game Of Life/sample/Main.class differ diff --git a/out/production/Game Of Life/sample/Rules.class b/out/production/Game Of Life/sample/Rules.class new file mode 100644 index 0000000..2de72f7 Binary files /dev/null and b/out/production/Game Of Life/sample/Rules.class differ diff --git a/out/production/Game Of Life/sample/golfx.fxml b/out/production/Game Of Life/sample/golfx.fxml new file mode 100644 index 0000000..563594d --- /dev/null +++ b/out/production/Game Of Life/sample/golfx.fxml @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +