-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
30 lines (30 loc) · 1.04 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<canvas id="game" style="width=1000px;height=1000px;"></canvas>
<label for="running">Run game</label>
<input id="running" type="checkbox" />
<input id="clear" type="button" value="Clear" />
<br />
A JavaScript/Canvas implementation of <a href="http://en.wikipedia.org/wiki/Conway's_Game_of_Life#Rules">Conway's Game of Life</a>.
<script src="board.js"></script>
<script src="game_of_life.js"></script>
<script type="text/javascript">
var canvas = document.getElementById('game')
var game = new GameOfLife(50, 50)
var board = new GameOfLifeGrid(game, canvas, 17)
board.render()
var set_running = document.getElementById('running')
set_running.addEventListener('click', function() {
board.running = set_running.checked
if (board.running) board.run()
})
document.getElementById('clear').addEventListener('click', function() {
game.clear()
board.render()
})
</script>
</body>
</html>