A simple Game of Life implementation in Java
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
852 B

  1. package edu.stuy.goldfish;
  2. import edu.stuy.goldfish.rules.*;
  3. public class Goldfish {
  4. private Grid _grid;
  5. private Render _render;
  6. public Goldfish() {
  7. int height = 128;
  8. int width = 128;
  9. _grid = new Grid(width, height);
  10. _render = new Render(width, height, _grid);
  11. }
  12. public void run() {
  13. _grid.getPatch(1,0).setState(1);
  14. _grid.getPatch(2,1).setState(1);
  15. _grid.getPatch(2,2).setState(1);
  16. _grid.getPatch(1,2).setState(1);
  17. _grid.getPatch(0,2).setState(1);
  18. while (true) {
  19. _grid = Conway.run(_grid);
  20. _render.setGrid(_grid);
  21. _render.run();
  22. _render.sleep();
  23. }
  24. }
  25. public static void main (String[] args) {
  26. Goldfish g = new Goldfish();
  27. g.run();
  28. }
  29. }