From 8e90b806a67159b2c1c0e657171801febda018a1 Mon Sep 17 00:00:00 2001
From: chris-hall-hu-cheng
Date: Sun, 28 Dec 2014 16:24:18 +0000
Subject: [PATCH] Altered HTML and JS to allow thresholds to be changed.
---
gameOfLife.html | 105 +++++++++++++++++++++++++++++++++++++++---------
gameoflife.js | 11 +----
2 files changed, 89 insertions(+), 27 deletions(-)
diff --git a/gameOfLife.html b/gameOfLife.html
index 239388a..40dadda 100644
--- a/gameOfLife.html
+++ b/gameOfLife.html
@@ -12,7 +12,11 @@
font-family: Monospace;
background-color: #f0f0f0;
margin: 0px;
- padding: 10px;
+ padding: 10px;
+}
+
+.controls-block {
+ padding: 20px;
}
@@ -38,23 +42,88 @@ Conway's Game Of Life... Now in 3D!
- Map size:
-
- Speed:
-
-
-
+
+ Map size:
+
+
+
+ Speed:
+
+
+
+ Death Threshold:
+
+ Breed Threshold:
+
+ Overcrowd Threshold:
+
+
+
+
+
+
This was a fun experiment, created by Samuel Levy.
diff --git a/gameoflife.js b/gameoflife.js
index cc63856..cfd3fe0 100644
--- a/gameoflife.js
+++ b/gameoflife.js
@@ -10,13 +10,6 @@ Grid = function() {
cube_h:Math.floor(HEIGHT/this.y),
cube_d:Math.floor(400/this.z),
- // thresholds
- th : {
- lonely: 1,
- breed: 5,
- overcrowd: 8
- },
-
// the actual map
map: [],
@@ -141,7 +134,7 @@ Grid = function() {
// transpose
if (cell) {
// is the cell lonely or overcrowded?
- if (n <= this.th.lonely || n >= this.th.overcrowd) {
+ if (n <= $('#lonely').val() || n >= $('#overcrowd').val()) {
// kill the cell off
scene.remove(cell);
} else {
@@ -150,7 +143,7 @@ Grid = function() {
}
} else {
// check if we're in the breed threshold
- if (n == this.th.breed) {
+ if (n == $('#breed').val()) {
var newcell = this.add_cell(i,j,k);
if (newcell) {