-
Notifications
You must be signed in to change notification settings - Fork 0
/
04_glider_static_static.html
53 lines (47 loc) · 1.36 KB
/
04_glider_static_static.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<script src="game_of_life.js"></script>
<script type="text/javascript">
'use strict';
var board;
var drawing;
var btnNextGen;
function runNextGen() {
board.calculateNextGen();
board.establishGen();
board.toHTMLCanvas(drawing);
}
function reset() {
board = new Board(20);
board.addCells([[3,3],[3,4], [3,5], [2,5],[1,4], [15,10], [14,11], [16,11], [14,12], [16,12], [15,13]]);
board.establishGen();
board.toHTMLCanvas(drawing);
}
function init() {
// elements and events
drawing = document.getElementById('drawing');
btnNextGen = document.getElementById('btnNextGen');
// board
reset();
// events
btnNextGen.addEventListener('click', runNextGen);
btnReset.addEventListener('click', reset);
}
window.onload = init;
</script>
<title>Game of life: glider vs. static life</title>
</head>
<body>
<h1>Game of life: glider vs. static life</h1>
<div>
<canvas id="drawing" width="400" height="400" style="border:2px solid #000000;">
</canvas>
</div>
<div>
<button id="btnNextGen">Next Generation</button>
<button id="btnReset">Reset</button>
</div>
</body>
</html>