mirror of
https://github.com/processing/processing4.git
synced 2026-05-03 09:26:25 +02:00
32 lines
613 B
Plaintext
32 lines
613 B
Plaintext
// Daniel Shiffman, Nature of Code
|
|
// <http://www.shiffman.net>
|
|
|
|
// A basic implementation of John Conway's Game of Life CA
|
|
// how could this be improved to use object oriented programming?
|
|
// think of it as similar to our particle system, with a "cell" class
|
|
// to describe each individual cell and a "cellular automata" class
|
|
// to describe a collection of cells
|
|
|
|
// Cells wrap around
|
|
|
|
GOL gol;
|
|
|
|
void setup() {
|
|
size(400, 400);
|
|
smooth();
|
|
gol = new GOL();
|
|
}
|
|
|
|
void draw() {
|
|
background(255);
|
|
|
|
gol.generate();
|
|
gol.display();
|
|
}
|
|
|
|
// reset board when mouse is pressed
|
|
void mousePressed() {
|
|
gol.init();
|
|
}
|
|
|