-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.htm
119 lines (104 loc) · 2.28 KB
/
index.htm
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!DOCTYPE html>
<html>
<head>
<title>Game of Life</title>
<meta charset="utf-8" />
<script src="game.js"></script>
<style>
html {
background-color: #f1f1f1;
font-family: sans-serif;
}
body,
section {
margin: 0 auto;
}
body {
display: flex;
flex-direction: column;
margin-bottom: 4rem;
}
h1 {
text-align: center;
margin-bottom: 1rem;
}
button {
background-color: #0078e7;
color: #fff;
cursor: pointer;
font-size: 1rem;
padding: 0.5em 1em;
}
button:disabled {
background-color: #ccc;
}
#controls {
margin-bottom: 2rem;
}
#grid {
border: 1px solid #808080;
}
.row {
margin: 0;
padding: 0;
flex: 1;
display: flex;
}
.cell {
height: 10px;
width: 10px;
margin: 0;
padding: 0;
background-color: #82b7dc;
border: 1px solid #808080;
}
.cell.live {
background-color: #1c1c1c;
}
</style>
</head>
<body>
<h1>Game of Life</h1>
<section>
<h2>Rules:</h2>
<ul>
<li>
any live cell with fewer than two live neighbours dies, as if by
under-population
</li>
<li>
any live cell with two or three live neighbours lives on to the next
generation
</li>
<li>
any live cell with more than three live neighbours dies, as if by
overpopulation
</li>
<li>
any dead cell with exactly three live neighbours becomes a live cell,
as if by reproduction
</li>
</ul>
<p>
Click squares to create living cells (clicking living cells kills them)
</p>
</section>
<section id="controls">
<button id="start">Start</button>
<button id="stop" disabled>Stop</button>
</section>
<section id="grid"></section>
<script>
const startButton = document.getElementById("start");
const stopButton = document.getElementById("stop");
startButton.onclick = event => {
startButton.setAttribute("disabled", true);
stopButton.removeAttribute("disabled");
};
stopButton.onclick = event => {
startButton.removeAttribute("disabled");
stopButton.setAttribute("disabled", true);
};
</script>
</body>
</html>