浏览代码

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

master
Ben Kurtovic 12 年前
父节点
当前提交
e4b441e7b9
共有 1 个文件被更改,包括 8 次插入14 次删除
  1. +8
    -14
      src/Goldfish.java

+ 8
- 14
src/Goldfish.java 查看文件

@@ -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();
}
}

正在加载...
取消
保存