-
Notifications
You must be signed in to change notification settings - Fork 0
/
minesweeper.html
82 lines (82 loc) · 1.92 KB
/
minesweeper.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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Minesweeper</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<style>
td {
border-style: inset;
width: 3em;
height: 3em;
text-align: center;
border-color: black;
}
.hidden {
background-color: gray;
}
.tile1:before {
content: "1";
}
.tile2:before {
content: "2";
}
.tile3:before {
content: "3";
}
.tile4:before {
content: "4";
}
.tile5:before {
content: "5";
}
.tile6:before {
content: "6";
}
.tile7:before {
content: "7";
}
.tile8:before {
content: "8";
}
.tile9:before {
content: "💣";
}
.flag:before {
content: "⚑";
}
</style>
</head>
<body>
<div id="app">
<label>Length<input v-model.number="length" type="number" min="0"></label>
<label>Width<input v-model.number="width" type="number" min="0"></label>
<label>Number of bombs<input v-model.number="bombCount" type="number" min="0"></label>
<button @click="++length; --length;">new game</button>
<table cellpadding="0" cellspacing="0">
<tbody>
<tr v-for="(n, i) in length">
<td v-for="(m, j) in width" v-bind:class="[game.tiles[i * game.horizontal + j].flagged ? 'flag' : game.tiles[i * game.horizontal + j].revealed ? 'tile' + game.tiles[i * game.horizontal + j].bombCount : 'hidden']" @contextmenu.prevent="game.flag(i, j); $forceUpdate();" @click="game.reveal(i, j); $forceUpdate();"></td>
</tr>
</tbody>
</table>
</div>
<script src="minesweeper.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
let app = new Vue({
el: "#app",
data: {
length: 0,
width: 0,
bombCount: 0
},
computed: {
game: function() {
return new Grid(this.length, this.width, this.bombCount);
}
}
})
</script>
</body>
</html>