Skip to content
Snippets Groups Projects
Commit 00fe2d79 authored by Will Billingsley's avatar Will Billingsley
Browse files

Revert "Removed key parts of code for tutorial"

This reverts commit 1ab924f6.
parent 47a3b603
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<div id="game" style="font-family: monospace; cursor: pointer;"> <div id="game" style="font-family: monospace; cursor: pointer;">
</div> </div>
<div> <div>
<button>Step</button> <button onclick="javascript: { gameOfLife.stepGame(); render(); }">Step</button>
</div> </div>
......
...@@ -2,6 +2,32 @@ ...@@ -2,6 +2,32 @@
function render() { function render() {
// You need to write this let gameDiv = document.getElementById("game")
gameDiv.innerHTML = ""
for (let y = 0; y < gameOfLife.getH(); y++) {
let row = document.createElement("div")
row.setAttribute("class", "gamerow")
gameDiv.appendChild(row)
for (let x = 0; x < gameOfLife.getW(); x++) {
let t = document.createElement("span")
if (gameOfLife.isAlive(x, y)) {
t.innerHTML = "#"
} else {
t.innerHTML = "."
}
let handler = function(evt) {
gameOfLife.toggleCell(x, y)
render()
}
t.addEventListener("mousedown", handler)
row.appendChild(t)
}
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment