forked from dashhuang/danmaku-game
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
173 lines (152 loc) · 4.64 KB
/
index.html
File metadata and controls
173 lines (152 loc) · 4.64 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<!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;
overflow: hidden;
background-color: #000;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-family: Arial, sans-serif;
touch-action: none; /* 防止触摸事件导致页面滚动 */
}
#game-container {
position: relative;
width: 480px;
height: 720px;
}
canvas {
position: absolute;
top: 0;
left: 0;
background: #000;
z-index: 1;
border: 1px solid #333;
}
.ui {
position: absolute;
width: 100%;
height: 100%;
z-index: 2;
pointer-events: none;
user-select: none;
}
.time {
position: absolute;
top: 20px;
left: 20px;
color: white;
font-size: 20px;
}
.game-over, .start-screen {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: white;
background: rgba(0, 0, 0, 0.8);
pointer-events: auto;
}
.game-over h2, .start-screen h1 {
margin-bottom: 30px;
font-size: 36px;
color: #fff;
text-shadow: 0 0 10px #0af;
}
.start-screen p {
margin: 10px 0;
font-size: 16px;
color: #ccc;
}
button {
padding: 10px 20px;
font-size: 18px;
cursor: pointer;
background: #0066cc;
color: white;
border: none;
border-radius: 5px;
margin-top: 20px;
pointer-events: auto;
}
button:hover {
background: #0088ff;
}
.hidden {
display: none;
}
.new-record {
color: #ff00ff;
font-weight: bold;
font-size: 18px;
text-shadow: 0 0 10px #ff00ff, 0 0 20px #ff00ff;
animation: pulse 1s infinite alternate;
}
@keyframes pulse {
from { opacity: 0.7; }
to { opacity: 1; }
}
.controls {
position: absolute;
bottom: 20px;
left: 0;
width: 100%;
text-align: center;
color: #aaa;
font-size: 14px;
}
/* 响应式样式 */
@media (max-width: 768px) {
.desktop-only {
display: none;
}
.controls {
display: none; /* 移动设备隐藏底部控制说明 */
}
}
@media (min-width: 769px) {
.mobile-only {
display: none;
}
}
</style>
</head>
<body>
<div id="game-container">
<canvas id="game-canvas"></canvas>
<div class="ui">
<div class="time">时间: <span id="time-value">00.00</span></div>
<div id="start-screen" class="start-screen">
<h1>弹幕飞机游戏</h1>
<p class="desktop-only">使用方向键或WASD移动飞机</p>
<p class="mobile-only">滑动屏幕控制飞机移动</p>
<p>躲避所有弹幕!坚持时间越长越好</p>
<button id="start-button">开始游戏</button>
</div>
<div id="game-over-screen" class="game-over hidden">
<h2>游戏结束</h2>
<p>坚持时间: <span id="final-time">00.00</span></p>
<p>最高记录: <span id="best-time">00.00</span></p>
<p id="new-record" class="hidden">恭喜!创造了新纪录!</p>
<button id="restart-button">再来一次</button>
</div>
<div class="controls">
使用方向键或WASD移动飞机
</div>
</div>
</div>
<script src="js/game.js"></script>
</body>
</html>