-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
114 lines (113 loc) · 3.66 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
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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>迷宫探险 - 网页版</title>
<style>
body {
margin: 0;
padding: 0;
/* display: flex; */
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f0f0;
overflow: hidden;
touch-action: none;
}
#game-container {
/* text-align: center; */
font-family: Arial, sans-serif;
max-width: 100%;
width: 95vw;/*添加宽度,避免在一些设备上过宽*/
}
#gameCanvas {
border: 1px solid black;
width: 100%;
max-width: min(100vw, 100vh);
height: auto;
aspect-ratio: 1 / 1;
}
#question-box {
position: absolute;
top: 30%;
left: 50%;
transform: translate(-50%, -50%);
background: white;
padding: 20px;
border: 2px solid black;
display: none;
max-width: 90%;
font-size: min(4vw, 4vh);
}
#controls {
/* margin-top: 10px; */
margin-bottom: 10px;
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 2px;
}
.button {
width: min(16vw, 16vh);
height: min(16vw, 16vh);
font-size: 5vw;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
touch-action: manipulation;
}
.button:active {
background-color: #45a049;
}
#dpad {
display: grid;
grid-template-areas:
" . up . "
"left mid right"
" . down . ";
gap: 5px;
}
#up { grid-area: up; }
#down { grid-area: mid; }
#left { grid-area: left; }
#right { grid-area: right; }
#mid { grid-area: mid; background: transparent; }
</style>
</head>
<body>
<div id="game-container">
<canvas id="gameCanvas" width="640" height="640"></canvas>
<div id="question-box">
<p id="question-text"></p>
<p id="options-text"></p>
<p>按 1-4 选择答案</p>
</div>
<div id="controls">
<div id="dpad">
<button id="up" class="button">↑</button>
<button id="left" class="button">←</button>
<button id="mid" class="button"></button>
<button id="right" class="button">→</button>
<button id="down" class="button">↓</button>
</div>
<div style="flex-basis: 100%;"></div>
<div style="margin-top: min(6vh,6vw);">
<button id="btn1" class="button">1</button>
<button id="btn2" class="button">2</button>
<button id="btn3" class="button">3</button>
<button id="btn4" class="button">4</button>
</div>
<div style="flex-basis: 100%;"></div>
<div>
<button id="btnR" class="button">R</button>
<button id="btnQ" class="button">Q</button>
</div>
</div>
</div>
<script src="game.js"></script>
</body>
</html>