Browse Source

Setup code should only be executed once. Make run() a loop.

master
Ben Kurtovic 11 years ago
parent
commit
e4b441e7b9
1 changed files with 8 additions and 14 deletions
  1. +8
    -14
      src/Goldfish.java

+ 8
- 14
src/Goldfish.java View File

@@ -1,6 +1,5 @@
package edu.stuy.goldfish;
import edu.stuy.goldfish.rules.*;
public class Goldfish {
@@ -8,34 +7,29 @@ public class Goldfish {
private Grid _grid;
private Render _render;
public Goldfish () {
public Goldfish() {
int height = 96;
int width = 96;
_render = new Render(width, height);
_grid = new Grid(width, height);
}
public void run () {
//TODO: make it run.
public void run() {
_grid.getPatch(1,0).setState(1);
_grid.getPatch(2,1).setState(1);
_grid.getPatch(2,2).setState(1);
_grid.getPatch(1,2).setState(1);
_grid.getPatch(0,2).setState(1);
System.out.println(_grid);
_grid = LifeWithoutDeath.run(_grid);
System.out.println("------------");
System.out.println(_grid);
_render.setGrid(_grid);
_render.run();
while (true) {
_grid = Conway.run(_grid);
_render.setGrid(_grid);
_render.run();
}
}
public static void main (String[] args) {
Goldfish g = new Goldfish();
while(true) {
g.run();
}
g.run();
}
}

Loading…
Cancel
Save