diff --git a/.classpath b/.classpath
deleted file mode 100644
index 59db47a..0000000
--- a/.classpath
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index ae3c172..0000000
--- a/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/bin/
diff --git a/.project b/.project
deleted file mode 100644
index 4cbf201..0000000
--- a/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
- GameOfLife
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
-
-
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 08ebd1b..0000000
--- a/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,11 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=9
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=9
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=9
diff --git a/README.md b/README.md
index 9184827..0c540a7 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,15 @@ My Conway's Game of Life project
***Not optimized yet***
This is just a little side project to work on optimization skills and mess around with different patterns in Conway's Game of Life.
-Download the project and open it in eclipse to edit, or to just run the project download and run the attached jar(***located in the included jar folder***).
+**To run**
+Step 1 : Download Repository
+Step 2 : Open Command Prompt and navigate to the folder you downloaded
+Step 3 : Enter the following commands
+ cd gameoflife
+ javac GameOfLife.java
+ javac Main.java
+ jar cmvf manifest.txt GameOfLife.jar ./*.java ./*.class
+ java -jar GameOfLife.java
+Step 4 : *Have fun using my Conway's Game of Life Program!!!*
-***Note: Requires Java 10***
\ No newline at end of file
+***Note: Requires Java 8***
\ No newline at end of file
diff --git a/src/gameoflife/Cell.java b/gameoflife/Cell.java
similarity index 95%
rename from src/gameoflife/Cell.java
rename to gameoflife/Cell.java
index dbfdc82..540dbee 100644
--- a/src/gameoflife/Cell.java
+++ b/gameoflife/Cell.java
@@ -1,85 +1,83 @@
-package gameoflife;
-
-import javafx.scene.shape.Rectangle;
-import javafx.event.EventHandler;
-import javafx.scene.input.MouseEvent;
-import javafx.scene.paint.Color;
-
-public class Cell extends Rectangle{
- public enum Status{
- ALIVE, DEAD
- }
- private Status status;
- private boolean aliveNextCycle, deadNextCycle;
- private int xLocation, yLocation;
- public Cell(Double width, Double height, int x, int y){
- setWidth(width);
- setHeight(height);
- setStroke(Color.LIGHTGRAY);
- setStatus(Status.DEAD);
- aliveNextCycle = false;
- deadNextCycle = false;
- xLocation = x;
- yLocation = y;
- setOnMousePressed(new EventHandler() {
- public void handle(MouseEvent me) {
- if(getStatus() == Status.DEAD) {
- setStatus(Status.ALIVE);
- }
- else {
- setStatus(Status.DEAD);
- }
- }
- });
- }
-
- public Status getStatus(){
- return status;
- }
-
- public void setStatus(Status status){
- if(status == Status.ALIVE){
- setFill(Color.BLACK);
- }
- else{
- setFill(Color.WHITE);
- }
- this.status = status;
- }
-
- public void updateStatus(){
- if(isAliveNextCycle()){
- setStatus(Status.ALIVE);
- makeAliveNextCycle(false);
- }
- else if(isDeadNextCycle()){
- setStatus(Status.DEAD);
- makeDeadNextCycle(false);
- }
- else{return;}
- }
-
- public boolean isAliveNextCycle(){
- return aliveNextCycle;
- }
-
- public boolean isDeadNextCycle(){
- return deadNextCycle;
- }
-
- public void makeAliveNextCycle(boolean aliveNextCycle){
- this.aliveNextCycle = aliveNextCycle;
- }
-
- public void makeDeadNextCycle(boolean deadNextCycle){
- this.deadNextCycle = deadNextCycle;
- }
-
- public int getXLocation() {
- return xLocation;
- }
-
- public int getYLocation() {
- return yLocation;
- }
-}
+import javafx.scene.shape.Rectangle;
+import javafx.event.EventHandler;
+import javafx.scene.input.MouseEvent;
+import javafx.scene.paint.Color;
+
+public class Cell extends Rectangle{
+ public enum Status{
+ ALIVE, DEAD
+ }
+ private Status status;
+ private boolean aliveNextCycle, deadNextCycle;
+ private int xLocation, yLocation;
+ public Cell(Double width, Double height, int x, int y){
+ setWidth(width);
+ setHeight(height);
+ setStroke(Color.LIGHTGRAY);
+ setStatus(Status.DEAD);
+ aliveNextCycle = false;
+ deadNextCycle = false;
+ xLocation = x;
+ yLocation = y;
+ setOnMousePressed(new EventHandler() {
+ public void handle(MouseEvent me) {
+ if(getStatus() == Status.DEAD) {
+ setStatus(Status.ALIVE);
+ }
+ else {
+ setStatus(Status.DEAD);
+ }
+ }
+ });
+ }
+
+ public Status getStatus(){
+ return status;
+ }
+
+ public void setStatus(Status status){
+ if(status == Status.ALIVE){
+ setFill(Color.BLACK);
+ }
+ else{
+ setFill(Color.WHITE);
+ }
+ this.status = status;
+ }
+
+ public void updateStatus(){
+ if(isAliveNextCycle()){
+ setStatus(Status.ALIVE);
+ makeAliveNextCycle(false);
+ }
+ else if(isDeadNextCycle()){
+ setStatus(Status.DEAD);
+ makeDeadNextCycle(false);
+ }
+ else{return;}
+ }
+
+ public boolean isAliveNextCycle(){
+ return aliveNextCycle;
+ }
+
+ public boolean isDeadNextCycle(){
+ return deadNextCycle;
+ }
+
+ public void makeAliveNextCycle(boolean aliveNextCycle){
+ this.aliveNextCycle = aliveNextCycle;
+ }
+
+ public void makeDeadNextCycle(boolean deadNextCycle){
+ this.deadNextCycle = deadNextCycle;
+ }
+
+ public int getXLocation() {
+ return xLocation;
+ }
+
+ public int getYLocation() {
+ return yLocation;
+ }
+}
diff --git a/src/gameoflife/GameOfLife.java b/gameoflife/GameOfLife.java
similarity index 96%
rename from src/gameoflife/GameOfLife.java
rename to gameoflife/GameOfLife.java
index 4b6cfe6..f24e68c 100644
--- a/src/gameoflife/GameOfLife.java
+++ b/gameoflife/GameOfLife.java
@@ -1,65 +1,63 @@
-package gameoflife;
-
-import javafx.application.Application;
-import javafx.scene.Scene;
-import javafx.scene.layout.GridPane;
-import javafx.stage.Stage;
-import javafx.geometry.Pos;
-import javafx.scene.control.Button;
-import javafx.animation.AnimationTimer;
-
-public class GameOfLife extends Application{
- private Cell[][] cells;
- @Override
- public void start(Stage primaryStage) throws Exception {
- cells = new Cell[64][64];
-
- GridPane root = new GridPane();
- root.setAlignment(Pos.CENTER);
-
- for(int i = 0; i < cells.length; i++){
- for(int j = 0; j < cells[i].length; j++){
- cells[i][j] = new Cell((double)10,(double)10, i, j);
- root.add(cells[i][j], i, j);
- }
- }
-
- AnimationTimer animate = new AnimationTimer(){
- @Override
- public void handle(long currentNanoTime){
- for(int i = 0; i< cells.length; i++){
- for(int j = 0; j < cells[i].length; j++){
- GameOfLifeRules.checkRules(cells, i, j);
- }
- }
- for(int i = 0; i< cells.length; i++){
- for(int j = 0; j < cells[i].length; j++){
- cells[i][j].updateStatus();
- }
- }
- try {Thread.sleep(50);}
- catch(Exception e) {}
- }
- };
-
- Button stop = new Button("Stop");
- stop.setOnAction(event->{
- animate.stop();
- });
-
- Button start = new Button("Start");
- start.setOnAction(event->{
- animate.start();
- });
-
- root.add(start, cells.length, cells[cells.length-1].length);
- root.add(stop, cells.length, cells[cells.length-1].length+1);
- root.setStyle("-fx-background-color: white");
-
- Scene scene = new Scene(root);
-
- primaryStage.setTitle("Conway's Game of Life");
- primaryStage.setScene(scene);
- primaryStage.show();
- }
+import javafx.application.Application;
+import javafx.scene.Scene;
+import javafx.scene.layout.GridPane;
+import javafx.stage.Stage;
+import javafx.geometry.Pos;
+import javafx.scene.control.Button;
+import javafx.animation.AnimationTimer;
+
+public class GameOfLife extends Application{
+ private Cell[][] cells;
+ @Override
+ public void start(Stage primaryStage) throws Exception {
+ cells = new Cell[64][64];
+
+ GridPane root = new GridPane();
+ root.setAlignment(Pos.CENTER);
+
+ for(int i = 0; i < cells.length; i++){
+ for(int j = 0; j < cells[i].length; j++){
+ cells[i][j] = new Cell((double)10,(double)10, i, j);
+ root.add(cells[i][j], i, j);
+ }
+ }
+
+ AnimationTimer animate = new AnimationTimer(){
+ @Override
+ public void handle(long currentNanoTime){
+ for(int i = 0; i< cells.length; i++){
+ for(int j = 0; j < cells[i].length; j++){
+ GameOfLifeRules.checkRules(cells, i, j);
+ }
+ }
+ for(int i = 0; i< cells.length; i++){
+ for(int j = 0; j < cells[i].length; j++){
+ cells[i][j].updateStatus();
+ }
+ }
+ try {Thread.sleep(50);}
+ catch(Exception e) {}
+ }
+ };
+
+ Button stop = new Button("Stop");
+ stop.setOnAction(event->{
+ animate.stop();
+ });
+
+ Button start = new Button("Start");
+ start.setOnAction(event->{
+ animate.start();
+ });
+
+ root.add(start, cells.length, cells[cells.length-1].length);
+ root.add(stop, cells.length, cells[cells.length-1].length+1);
+ root.setStyle("-fx-background-color: white");
+
+ Scene scene = new Scene(root);
+
+ primaryStage.setTitle("Conway's Game of Life");
+ primaryStage.setScene(scene);
+ primaryStage.show();
+ }
}
\ No newline at end of file
diff --git a/src/gameoflife/GameOfLifeRules.java b/gameoflife/GameOfLifeRules.java
similarity index 95%
rename from src/gameoflife/GameOfLifeRules.java
rename to gameoflife/GameOfLifeRules.java
index 7f3d4ef..71597da 100644
--- a/src/gameoflife/GameOfLifeRules.java
+++ b/gameoflife/GameOfLifeRules.java
@@ -1,35 +1,33 @@
-package gameoflife;
-
-public class GameOfLifeRules {
- public static void checkRules(Cell[][] cells, int x, int y) {
- int aliveNeighbors = 0;
- for(int i = y-1; i <= y + 1; i++){
- if(i >= 0 && i < cells[x].length){
- if(x-1 >= 0){
- if(cells[x-1][i].getStatus() == Cell.Status.ALIVE){
- aliveNeighbors++;
- }
- }
- if(i != y){
- if(cells[x][i].getStatus() == Cell.Status.ALIVE){
- aliveNeighbors++;
- }
- }
- if(x+1 < cells.length){
- if(cells[x+1][i].getStatus() == Cell.Status.ALIVE){
- aliveNeighbors++;
- }
- }
- }
- }
- if((aliveNeighbors == 2 || aliveNeighbors == 3) && cells[x][y].getStatus() == Cell.Status.ALIVE){
- cells[x][y].makeAliveNextCycle(true);
- }
- else if((aliveNeighbors < 2 || aliveNeighbors > 3) && cells[x][y].getStatus() == Cell.Status.ALIVE){
- cells[x][y].makeDeadNextCycle(true);
- }
- if(aliveNeighbors == 3 && cells[x][y].getStatus() == Cell.Status.DEAD){
- cells[x][y].makeAliveNextCycle(true);
- }
- }
-}
+public class GameOfLifeRules {
+ public static void checkRules(Cell[][] cells, int x, int y) {
+ int aliveNeighbors = 0;
+ for(int i = y-1; i <= y + 1; i++){
+ if(i >= 0 && i < cells[x].length){
+ if(x-1 >= 0){
+ if(cells[x-1][i].getStatus() == Cell.Status.ALIVE){
+ aliveNeighbors++;
+ }
+ }
+ if(i != y){
+ if(cells[x][i].getStatus() == Cell.Status.ALIVE){
+ aliveNeighbors++;
+ }
+ }
+ if(x+1 < cells.length){
+ if(cells[x+1][i].getStatus() == Cell.Status.ALIVE){
+ aliveNeighbors++;
+ }
+ }
+ }
+ }
+ if((aliveNeighbors == 2 || aliveNeighbors == 3) && cells[x][y].getStatus() == Cell.Status.ALIVE){
+ cells[x][y].makeAliveNextCycle(true);
+ }
+ else if((aliveNeighbors < 2 || aliveNeighbors > 3) && cells[x][y].getStatus() == Cell.Status.ALIVE){
+ cells[x][y].makeDeadNextCycle(true);
+ }
+ if(aliveNeighbors == 3 && cells[x][y].getStatus() == Cell.Status.DEAD){
+ cells[x][y].makeAliveNextCycle(true);
+ }
+ }
+}
diff --git a/src/gameoflife/Main.java b/gameoflife/Main.java
similarity index 83%
rename from src/gameoflife/Main.java
rename to gameoflife/Main.java
index 3d7bb1d..8ed329e 100644
--- a/src/gameoflife/Main.java
+++ b/gameoflife/Main.java
@@ -1,9 +1,7 @@
-package gameoflife;
-
-import javafx.application.Application;
-
-public class Main {
- public static void main(String[] args) {
- Application.launch(GameOfLife.class, args);
- }
-}
+import javafx.application.Application;
+
+public class Main {
+ public static void main(String[] args) {
+ Application.launch(GameOfLife.class, args);
+ }
+}
diff --git a/gameoflife/manifest.mf b/gameoflife/manifest.mf
new file mode 100644
index 0000000..3e22e7e
--- /dev/null
+++ b/gameoflife/manifest.mf
@@ -0,0 +1 @@
+Main-Class: Main
diff --git a/jar/GameOfLife.jar b/jar/GameOfLife.jar
deleted file mode 100644
index bafe333..0000000
Binary files a/jar/GameOfLife.jar and /dev/null differ