-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
70 lines (66 loc) · 1.47 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
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
<head>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="stylesheet" href="assets/css/hakoirimusume.css" />
</head>
<style>
body {
background: #121212;
color: white;
}
h2 {
text-align: center;
}
#game {
width: 60vh;
margin: 1rem auto;
}
@media only screen and (max-width: 460px) {
#game {
width: 90%;
}
}
</style>
<body>
<h2>箱入り娘</h2>
<div id="game-help">
<div>
<span id="move-count"></span>
moves
</div>
<button id="reset">RESET</button>
<div id="game"></div>
</div>
<script src="dist/iife/sliding-puzzles.js"></script>
<script>
function sol(s) {
return s.pieces.find((p) => p.name === 'K').position === 13;
}
function win(s) {
setTimeout(() => {
wscreen = document.createElement('div');
wscreen.classList.add('win');
s.elements.main.appendChild(wscreen);
}, 50);
}
function move(s) {
mcnt = document.getElementById('move-count');
mcnt.innerHTML = s.moves;
}
function init() {
mcnt = document.getElementById('move-count');
mcnt.innerHTML = '0';
SlidingPuzzles(
document.getElementById('game'),
'G1 K K G2/G1 K K G2/B S S R/B N L R/ P1 . . P2',
{
solution: sol,
onVictory: win,
onMove: move,
},
);
}
btn = document.getElementById('reset');
btn.onclick = init;
init();
</script>
</body>