Add 1 files
Browse files- index.html +382 -552
index.html
CHANGED
|
@@ -1,582 +1,412 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
-
<html lang="
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
-
<
|
|
|
|
| 9 |
<style>
|
| 10 |
-
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap');
|
| 11 |
-
|
| 12 |
body {
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
.hero {
|
| 18 |
-
background: linear-gradient(rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.9)),
|
| 19 |
-
url('https://images.unsplash.com/photo-1603569283847-aa295f0d016a?ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80');
|
| 20 |
-
background-size: cover;
|
| 21 |
-
background-position: center;
|
| 22 |
-
}
|
| 23 |
-
|
| 24 |
-
.product-card:hover {
|
| 25 |
-
transform: translateY(-10px);
|
| 26 |
-
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
|
| 27 |
-
}
|
| 28 |
-
|
| 29 |
-
.flavor-card {
|
| 30 |
-
transition: all 0.3s ease;
|
| 31 |
}
|
| 32 |
-
|
| 33 |
-
.flavor-card:hover {
|
| 34 |
-
transform: scale(1.05);
|
| 35 |
-
}
|
| 36 |
-
|
| 37 |
-
.nav-link {
|
| 38 |
position: relative;
|
|
|
|
|
|
|
| 39 |
}
|
| 40 |
-
|
| 41 |
-
.nav-link:after {
|
| 42 |
-
content: '';
|
| 43 |
position: absolute;
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
}
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
| 53 |
width: 100%;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
}
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
width: 100%;
|
| 58 |
}
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
}
|
| 63 |
</style>
|
| 64 |
</head>
|
| 65 |
-
<body
|
| 66 |
-
<
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
<
|
| 70 |
-
|
| 71 |
-
<div class="flex items-center">
|
| 72 |
-
<a href="#" class="text-2xl font-bold text-indigo-600 flex items-center">
|
| 73 |
-
<i class="fas fa-leaf mr-2"></i>
|
| 74 |
-
简爱酸奶
|
| 75 |
-
</a>
|
| 76 |
-
</div>
|
| 77 |
-
|
| 78 |
-
<!-- 导航链接 -->
|
| 79 |
-
<div class="hidden md:flex items-center space-x-8">
|
| 80 |
-
<a href="#home" class="nav-link text-gray-800 hover:text-indigo-600">首页</a>
|
| 81 |
-
<a href="#products" class="nav-link text-gray-800 hover:text-indigo-600">产品系列</a>
|
| 82 |
-
<a href="#story" class="nav-link text-gray-800 hover:text-indigo-600">品牌故事</a>
|
| 83 |
-
<a href="#nutrition" class="nav-link text-gray-800 hover:text-indigo-600">营养健康</a>
|
| 84 |
-
<a href="#contact" class="nav-link text-gray-800 hover:text-indigo-600">联系我们</a>
|
| 85 |
-
</div>
|
| 86 |
-
|
| 87 |
-
<!-- 移动端菜单按钮 -->
|
| 88 |
-
<div class="md:hidden">
|
| 89 |
-
<button id="menu-btn" class="text-gray-800 focus:outline-none">
|
| 90 |
-
<i class="fas fa-bars text-2xl"></i>
|
| 91 |
-
</button>
|
| 92 |
-
</div>
|
| 93 |
-
</div>
|
| 94 |
-
|
| 95 |
-
<!-- 移动端菜单 -->
|
| 96 |
-
<div id="mobile-menu" class="hidden md:hidden mt-4 pb-4">
|
| 97 |
-
<a href="#home" class="block py-2 text-gray-800 hover:text-indigo-600">首页</a>
|
| 98 |
-
<a href="#products" class="block py-2 text-gray-800 hover:text-indigo-600">产品系列</a>
|
| 99 |
-
<a href="#story" class="block py-2 text-gray-800 hover:text-indigo-600">品牌故事</a>
|
| 100 |
-
<a href="#nutrition" class="block py-2 text-gray-800 hover:text-indigo-600">营养健康</a>
|
| 101 |
-
<a href="#contact" class="block py-2 text-gray-800 hover:text-indigo-600">联系我们</a>
|
| 102 |
-
</div>
|
| 103 |
</div>
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
<div class="md:w-1/2 mb-10 md:mb-0">
|
| 110 |
-
<h1 class="text-4xl md:text-5xl font-bold text-gray-800 mb-6">纯净无添加的低温酸奶</h1>
|
| 111 |
-
<p class="text-lg text-gray-600 mb-8">简爱酸奶,只选用优质奶源,0添加蔗糖、0添加香精、0添加防腐剂,给您最纯净的酸奶体验。</p>
|
| 112 |
-
<div class="flex space-x-4">
|
| 113 |
-
<a href="#products" class="bg-indigo-600 text-white px-6 py-3 rounded-lg hover:bg-indigo-700 transition duration-300">探索产品</a>
|
| 114 |
-
<a href="#story" class="border border-indigo-600 text-indigo-600 px-6 py-3 rounded-lg hover:bg-indigo-50 transition duration-300">品牌故事</a>
|
| 115 |
-
</div>
|
| 116 |
-
</div>
|
| 117 |
-
<div class="md:w-1/2 flex justify-center">
|
| 118 |
-
<img src="https://images.unsplash.com/photo-1577234286642-fc512a5f8f11?ixlib=rb-1.2.1&auto=format&fit=crop&w=634&q=80" alt="简爱酸奶" class="rounded-lg shadow-xl max-w-md w-full">
|
| 119 |
-
</div>
|
| 120 |
</div>
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
<h2 class="text-3xl font-bold text-center text-gray-800 mb-12">为什么选择简爱酸奶</h2>
|
| 127 |
-
<div class="grid md:grid-cols-3 gap-8">
|
| 128 |
-
<div class="bg-white p-8 rounded-lg shadow-md text-center">
|
| 129 |
-
<div class="text-indigo-600 mb-4">
|
| 130 |
-
<i class="fas fa-seedling text-4xl"></i>
|
| 131 |
-
</div>
|
| 132 |
-
<h3 class="text-xl font-semibold mb-3">纯净配方</h3>
|
| 133 |
-
<p class="text-gray-600">0添加蔗糖、0添加香精、0添加防腐剂,只有生牛乳和乳酸菌,回归酸奶本真。</p>
|
| 134 |
-
</div>
|
| 135 |
-
<div class="bg-white p-8 rounded-lg shadow-md text-center">
|
| 136 |
-
<div class="text-indigo-600 mb-4">
|
| 137 |
-
<i class="fas fa-temperature-low text-4xl"></i>
|
| 138 |
-
</div>
|
| 139 |
-
<h3 class="text-xl font-semibold mb-3">低温发酵</h3>
|
| 140 |
-
<p class="text-gray-600">采用低温慢发酵工艺,保留更多活性乳酸菌,口感更细腻醇厚。</p>
|
| 141 |
-
</div>
|
| 142 |
-
<div class="bg-white p-8 rounded-lg shadow-md text-center">
|
| 143 |
-
<div class="text-indigo-600 mb-4">
|
| 144 |
-
<i class="fas fa-cow text-4xl"></i>
|
| 145 |
-
</div>
|
| 146 |
-
<h3 class="text-xl font-semibold mb-3">优质奶源</h3>
|
| 147 |
-
<p class="text-gray-600">精选优质牧场奶源,蛋白质含量≥3.2g/100g,奶香浓郁,营养丰富。</p>
|
| 148 |
-
</div>
|
| 149 |
-
</div>
|
| 150 |
</div>
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
<
|
| 159 |
-
<!-- 产品1 -->
|
| 160 |
-
<div class="product-card bg-white rounded-lg overflow-hidden shadow-lg transition duration-300">
|
| 161 |
-
<div class="relative overflow-hidden h-64">
|
| 162 |
-
<img src="https://images.unsplash.com/photo-1562059390-a761a084768e?ixlib=rb-1.2.1&auto=format&fit=crop&w=634&q=80" alt="原味酸奶" class="w-full h-full object-cover">
|
| 163 |
-
<div class="absolute top-4 right-4 bg-indigo-600 text-white px-3 py-1 rounded-full text-sm">热销</div>
|
| 164 |
-
</div>
|
| 165 |
-
<div class="p-6">
|
| 166 |
-
<h3 class="text-xl font-semibold mb-2">简爱原味酸奶</h3>
|
| 167 |
-
<p class="text-gray-600 mb-4">只有生牛乳和乳酸菌,无任何添加,还原酸奶最本真的味道。</p>
|
| 168 |
-
<div class="flex justify-between items-center">
|
| 169 |
-
<span class="text-indigo-600 font-bold">¥8.9/135g</span>
|
| 170 |
-
<button class="bg-indigo-600 text-white px-4 py-2 rounded-lg hover:bg-indigo-700 transition duration-300">加入购物车</button>
|
| 171 |
-
</div>
|
| 172 |
-
</div>
|
| 173 |
-
</div>
|
| 174 |
-
|
| 175 |
-
<!-- 产品2 -->
|
| 176 |
-
<div class="product-card bg-white rounded-lg overflow-hidden shadow-lg transition duration-300">
|
| 177 |
-
<div class="relative overflow-hidden h-64">
|
| 178 |
-
<img src="https://images.unsplash.com/photo-1550583724-b2692b85b150?ixlib=rb-1.2.1&auto=format&fit=crop&w=634&q=80" alt="0蔗糖酸奶" class="w-full h-full object-cover">
|
| 179 |
-
</div>
|
| 180 |
-
<div class="p-6">
|
| 181 |
-
<h3 class="text-xl font-semibold mb-2">简爱0蔗糖酸奶</h3>
|
| 182 |
-
<p class="text-gray-600 mb-4">0添加蔗糖,使用天然代糖,适合控糖人群的健康选择。</p>
|
| 183 |
-
<div class="flex justify-between items-center">
|
| 184 |
-
<span class="text-indigo-600 font-bold">¥9.9/135g</span>
|
| 185 |
-
<button class="bg-indigo-600 text-white px-4 py-2 rounded-lg hover:bg-indigo-700 transition duration-300">加入购物车</button>
|
| 186 |
-
</div>
|
| 187 |
-
</div>
|
| 188 |
-
</div>
|
| 189 |
-
|
| 190 |
-
<!-- 产品3 -->
|
| 191 |
-
<div class="product-card bg-white rounded-lg overflow-hidden shadow-lg transition duration-300">
|
| 192 |
-
<div class="relative overflow-hidden h-64">
|
| 193 |
-
<img src="https://images.unsplash.com/photo-1577234286642-fc512a5f8f11?ixlib=rb-1.2.1&auto=format&fit=crop&w=634&q=80" alt="高蛋白酸奶" class="w-full h-full object-cover">
|
| 194 |
-
</div>
|
| 195 |
-
<div class="p-6">
|
| 196 |
-
<h3 class="text-xl font-semibold mb-2">简爱高蛋白酸奶</h3>
|
| 197 |
-
<p class="text-gray-600 mb-4">蛋白质含量≥6.0g/100g,健身人士的理想选择。</p>
|
| 198 |
-
<div class="flex justify-between items-center">
|
| 199 |
-
<span class="text-indigo-600 font-bold">¥12.9/135g</span>
|
| 200 |
-
<button class="bg-indigo-600 text-white px-4 py-2 rounded-lg hover:bg-indigo-700 transition duration-300">加入购物车</button>
|
| 201 |
-
</div>
|
| 202 |
-
</div>
|
| 203 |
-
</div>
|
| 204 |
-
</div>
|
| 205 |
-
|
| 206 |
-
<!-- 更多口味 -->
|
| 207 |
-
<div class="mt-16">
|
| 208 |
-
<h3 class="text-2xl font-semibold text-center mb-8">更多美味口味</h3>
|
| 209 |
-
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-4">
|
| 210 |
-
<div class="flavor-card bg-white p-4 rounded-lg shadow-md text-center cursor-pointer">
|
| 211 |
-
<div class="bg-blue-100 w-16 h-16 mx-auto rounded-full flex items-center justify-center mb-2">
|
| 212 |
-
<i class="fas fa-strawberry text-2xl text-red-500"></i>
|
| 213 |
-
</div>
|
| 214 |
-
<span class="text-sm font-medium">草莓味</span>
|
| 215 |
-
</div>
|
| 216 |
-
<div class="flavor-card bg-white p-4 rounded-lg shadow-md text-center cursor-pointer">
|
| 217 |
-
<div class="bg-blue-100 w-16 h-16 mx-auto rounded-full flex items-center justify-center mb-2">
|
| 218 |
-
<i class="fas fa-apple-alt text-2xl text-green-500"></i>
|
| 219 |
-
</div>
|
| 220 |
-
<span class="text-sm font-medium">苹果味</span>
|
| 221 |
-
</div>
|
| 222 |
-
<div class="flavor-card bg-white p-4 rounded-lg shadow-md text-center cursor-pointer">
|
| 223 |
-
<div class="bg-blue-100 w-16 h-16 mx-auto rounded-full flex items-center justify-center mb-2">
|
| 224 |
-
<i class="fas fa-lemon text-2xl text-yellow-400"></i>
|
| 225 |
-
</div>
|
| 226 |
-
<span class="text-sm font-medium">柠檬味</span>
|
| 227 |
-
</div>
|
| 228 |
-
<div class="flavor-card bg-white p-4 rounded-lg shadow-md text-center cursor-pointer">
|
| 229 |
-
<div class="bg-blue-100 w-16 h-16 mx-auto rounded-full flex items-center justify-center mb-2">
|
| 230 |
-
<i class="fas fa-pepper-hot text-2xl text-orange-500"></i>
|
| 231 |
-
</div>
|
| 232 |
-
<span class="text-sm font-medium">芒果味</span>
|
| 233 |
-
</div>
|
| 234 |
-
<div class="flavor-card bg-white p-4 rounded-lg shadow-md text-center cursor-pointer">
|
| 235 |
-
<div class="bg-blue-100 w-16 h-16 mx-auto rounded-full flex items-center justify-center mb-2">
|
| 236 |
-
<i class="fas fa-seedling text-2xl text-blue-500"></i>
|
| 237 |
-
</div>
|
| 238 |
-
<span class="text-sm font-medium">蓝莓味</span>
|
| 239 |
-
</div>
|
| 240 |
-
<div class="flavor-card bg-white p-4 rounded-lg shadow-md text-center cursor-pointer">
|
| 241 |
-
<div class="bg-blue-100 w-16 h-16 mx-auto rounded-full flex items-center justify-center mb-2">
|
| 242 |
-
<i class="fas fa-plus text-2xl text-indigo-500"></i>
|
| 243 |
-
</div>
|
| 244 |
-
<span class="text-sm font-medium">更多口味</span>
|
| 245 |
-
</div>
|
| 246 |
-
</div>
|
| 247 |
-
</div>
|
| 248 |
</div>
|
| 249 |
-
</
|
| 250 |
|
| 251 |
-
<
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
<p class="text-indigo-800 italic">"我们相信,好的酸奶不需要复杂的配方,只需要纯净的原料和用心的工艺。"</p>
|
| 267 |
-
</div>
|
| 268 |
-
</div>
|
| 269 |
-
</div>
|
| 270 |
-
|
| 271 |
-
<!-- 品牌历程 -->
|
| 272 |
-
<div class="mt-16">
|
| 273 |
-
<h3 class="text-2xl font-semibold text-center mb-8">品牌历程</h3>
|
| 274 |
-
<div class="relative">
|
| 275 |
-
<!-- 时间线 -->
|
| 276 |
-
<div class="border-l-2 border-indigo-600 absolute h-full left-1/2 transform -translate-x-1/2"></div>
|
| 277 |
-
|
| 278 |
-
<!-- 里程碑1 -->
|
| 279 |
-
<div class="mb-8 flex justify-between items-center w-full">
|
| 280 |
-
<div class="w-5/12 px-4 py-3 bg-white rounded-lg shadow-md">
|
| 281 |
-
<h4 class="font-bold text-indigo-600 mb-1">2015年</h4>
|
| 282 |
-
<p class="text-gray-600">简爱品牌成立,推出第一款原味无添加酸奶</p>
|
| 283 |
-
</div>
|
| 284 |
-
<div class="w-1/12 flex justify-center">
|
| 285 |
-
<div class="w-6 h-6 bg-indigo-600 rounded-full"></div>
|
| 286 |
-
</div>
|
| 287 |
-
<div class="w-5/12"></div>
|
| 288 |
-
</div>
|
| 289 |
-
|
| 290 |
-
<!-- 里程碑2 -->
|
| 291 |
-
<div class="mb-8 flex justify-between items-center w-full flex-row-reverse">
|
| 292 |
-
<div class="w-5/12 px-4 py-3 bg-white rounded-lg shadow-md text-right">
|
| 293 |
-
<h4 class="font-bold text-indigo-600 mb-1">2017年</h4>
|
| 294 |
-
<p class="text-gray-600">获得"中国食品健康七星奖"</p>
|
| 295 |
-
</div>
|
| 296 |
-
<div class="w-1/12 flex justify-center">
|
| 297 |
-
<div class="w-6 h-6 bg-indigo-600 rounded-full"></div>
|
| 298 |
-
</div>
|
| 299 |
-
<div class="w-5/12"></div>
|
| 300 |
-
</div>
|
| 301 |
-
|
| 302 |
-
<!-- 里程碑3 -->
|
| 303 |
-
<div class="mb-8 flex justify-between items-center w-full">
|
| 304 |
-
<div class="w-5/12 px-4 py-3 bg-white rounded-lg shadow-md">
|
| 305 |
-
<h4 class="font-bold text-indigo-600 mb-1">2019年</h4>
|
| 306 |
-
<p class="text-gray-600">年销售额突破10亿元,成为高端低温酸奶领导品牌</p>
|
| 307 |
-
</div>
|
| 308 |
-
<div class="w-1/12 flex justify-center">
|
| 309 |
-
<div class="w-6 h-6 bg-indigo-600 rounded-full"></div>
|
| 310 |
-
</div>
|
| 311 |
-
<div class="w-5/12"></div>
|
| 312 |
-
</div>
|
| 313 |
-
|
| 314 |
-
<!-- 里程碑4 -->
|
| 315 |
-
<div class="flex justify-between items-center w-full flex-row-reverse">
|
| 316 |
-
<div class="w-5/12 px-4 py-3 bg-white rounded-lg shadow-md text-right">
|
| 317 |
-
<h4 class="font-bold text-indigo-600 mb-1">2022年</h4>
|
| 318 |
-
<p class="text-gray-600">建立自有牧场,实现从牧场到餐桌的全产业链控制</p>
|
| 319 |
-
</div>
|
| 320 |
-
<div class="w-1/12 flex justify-center">
|
| 321 |
-
<div class="w-6 h-6 bg-indigo-600 rounded-full"></div>
|
| 322 |
-
</div>
|
| 323 |
-
<div class="w-5/12"></div>
|
| 324 |
-
</div>
|
| 325 |
-
</div>
|
| 326 |
-
</div>
|
| 327 |
-
</div>
|
| 328 |
-
</section>
|
| 329 |
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
</div>
|
| 407 |
-
<div class="bg-indigo-50 p-6 rounded-lg">
|
| 408 |
-
<div class="flex items-center mb-4">
|
| 409 |
-
<div class="bg-indigo-100 p-3 rounded-full mr-4">
|
| 410 |
-
<i class="fas fa-temperature-low text-indigo-600"></i>
|
| 411 |
-
</div>
|
| 412 |
-
<h4 class="text-lg font-semibold">储存方式</h4>
|
| 413 |
-
</div>
|
| 414 |
-
<p class="text-gray-600">请置于2-6℃冷藏保存,开封后请尽快食用,以保证最佳口感和活性菌数量。</p>
|
| 415 |
-
</div>
|
| 416 |
-
<div class="bg-indigo-50 p-6 rounded-lg">
|
| 417 |
-
<div class="flex items-center mb-4">
|
| 418 |
-
<div class="bg-indigo-100 p-3 rounded-full mr-4">
|
| 419 |
-
<i class="fas fa-users text-indigo-600"></i>
|
| 420 |
-
</div>
|
| 421 |
-
<h4 class="text-lg font-semibold">适宜人群</h4>
|
| 422 |
-
</div>
|
| 423 |
-
<p class="text-gray-600">适合3岁以上儿童及成人,特别是消化不良、需要补钙或控制体重的人群。</p>
|
| 424 |
-
</div>
|
| 425 |
-
</div>
|
| 426 |
-
</div>
|
| 427 |
-
</section>
|
| 428 |
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 452 |
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
<img src="https://randomuser.me/api/portraits/men/75.jpg" alt="客户" class="w-12 h-12 rounded-full mr-4">
|
| 457 |
-
<div>
|
| 458 |
-
<h4 class="font-semibold">张先生</h4>
|
| 459 |
-
<div class="flex text-yellow-400">
|
| 460 |
-
<i class="fas fa-star"></i>
|
| 461 |
-
<i class="fas fa-star"></i>
|
| 462 |
-
<i class="fas fa-star"></i>
|
| 463 |
-
<i class="fas fa-star"></i>
|
| 464 |
-
<i class="fas fa-star"></i>
|
| 465 |
-
</div>
|
| 466 |
-
</div>
|
| 467 |
-
</div>
|
| 468 |
-
<p class="text-gray-600">"健身多年,一直在寻找高蛋白低糖的酸奶,简爱的高蛋白系列完美满足我的需求,口感也很棒!"</p>
|
| 469 |
-
</div>
|
| 470 |
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
<h4 class="font-semibold">王阿姨</h4>
|
| 477 |
-
<div class="flex text-yellow-400">
|
| 478 |
-
<i class="fas fa-star"></i>
|
| 479 |
-
<i class="fas fa-star"></i>
|
| 480 |
-
<i class="fas fa-star"></i>
|
| 481 |
-
<i class="fas fa-star"></i>
|
| 482 |
-
<i class="fas fa-star-half-alt"></i>
|
| 483 |
-
</div>
|
| 484 |
-
</div>
|
| 485 |
-
</div>
|
| 486 |
-
<p class="text-gray-600">"年纪大了消化不好,医生建议多喝酸奶。简爱的原味酸奶很纯正,喝了之后肠胃舒服多了。"</p>
|
| 487 |
-
</div>
|
| 488 |
-
</div>
|
| 489 |
-
</div>
|
| 490 |
-
</section>
|
| 491 |
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 557 |
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
<div class="grid md:grid-cols-4 gap-6">
|
| 564 |
-
<div class="bg-gray-50 p-6 rounded-lg text-center">
|
| 565 |
-
<div class="bg-indigo-100 w-16 h-16 mx-auto rounded-full flex items-center justify-center mb-4">
|
| 566 |
-
<i class="fas fa-store text-2xl text-indigo-600"></i>
|
| 567 |
-
</div>
|
| 568 |
-
<h3 class="text-lg font-semibold mb-2">线下商超</h3>
|
| 569 |
-
<p class="text-gray-600 text-sm">全国各大超市、便利店有售</p>
|
| 570 |
-
</div>
|
| 571 |
-
<div class="bg-gray-50 p-6 rounded-lg text-center">
|
| 572 |
-
<div class="bg-indigo-100 w-16 h-16 mx-auto rounded-full flex items-center justify-center mb-4">
|
| 573 |
-
<i class="fas fa-mobile-alt text-2xl text-indigo-600"></i>
|
| 574 |
-
</div>
|
| 575 |
-
<h3 class="text-lg font-semibold mb-2">官方小程序</h3>
|
| 576 |
-
<p class="text-gray-600 text-sm">扫码进入简爱官方商城</p>
|
| 577 |
-
</div>
|
| 578 |
-
<div class="bg-gray-50 p-6 rounded-lg text-center">
|
| 579 |
-
<div class="bg-indigo-100 w-16 h-16 mx-auto rounded-full flex items-center justify-center mb-4">
|
| 580 |
-
<i class="fas fa-shopping-cart text-2xl text-indigo-600"></i>
|
| 581 |
-
</div
|
| 582 |
</html>
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>3D飞行射击游戏</title>
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
|
| 9 |
+
<script src="https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/controls/PointerLockControls.js"></script>
|
| 10 |
<style>
|
|
|
|
|
|
|
| 11 |
body {
|
| 12 |
+
margin: 0;
|
| 13 |
+
overflow: hidden;
|
| 14 |
+
font-family: 'Arial', sans-serif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
}
|
| 16 |
+
#game-container {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
position: relative;
|
| 18 |
+
width: 100vw;
|
| 19 |
+
height: 100vh;
|
| 20 |
}
|
| 21 |
+
#crosshair {
|
|
|
|
|
|
|
| 22 |
position: absolute;
|
| 23 |
+
top: 50%;
|
| 24 |
+
left: 50%;
|
| 25 |
+
width: 20px;
|
| 26 |
+
height: 20px;
|
| 27 |
+
transform: translate(-50%, -50%);
|
| 28 |
+
pointer-events: none;
|
| 29 |
}
|
| 30 |
+
#start-screen, #game-over {
|
| 31 |
+
position: absolute;
|
| 32 |
+
top: 0;
|
| 33 |
+
left: 0;
|
| 34 |
width: 100%;
|
| 35 |
+
height: 100%;
|
| 36 |
+
display: flex;
|
| 37 |
+
flex-direction: column;
|
| 38 |
+
justify-content: center;
|
| 39 |
+
align-items: center;
|
| 40 |
+
background-color: rgba(0, 0, 0, 0.7);
|
| 41 |
+
color: white;
|
| 42 |
+
z-index: 100;
|
| 43 |
}
|
| 44 |
+
#game-over {
|
| 45 |
+
display: none;
|
|
|
|
| 46 |
}
|
| 47 |
+
button {
|
| 48 |
+
margin-top: 20px;
|
| 49 |
+
padding: 10px 20px;
|
| 50 |
+
font-size: 1.2em;
|
| 51 |
+
background-color: #4CAF50;
|
| 52 |
+
color: white;
|
| 53 |
+
border: none;
|
| 54 |
+
border-radius: 5px;
|
| 55 |
+
cursor: pointer;
|
| 56 |
+
}
|
| 57 |
+
button:hover {
|
| 58 |
+
background-color: #45a049;
|
| 59 |
+
}
|
| 60 |
+
#hud {
|
| 61 |
+
position: absolute;
|
| 62 |
+
top: 10px;
|
| 63 |
+
left: 10px;
|
| 64 |
+
color: white;
|
| 65 |
+
font-size: 1.5em;
|
| 66 |
+
z-index: 10;
|
| 67 |
+
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
|
| 68 |
}
|
| 69 |
</style>
|
| 70 |
</head>
|
| 71 |
+
<body>
|
| 72 |
+
<div id="game-container">
|
| 73 |
+
<div id="start-screen">
|
| 74 |
+
<h1 class="text-4xl font-bold mb-4">3D飞行射击游戏</h1>
|
| 75 |
+
<p class="text-xl mb-6">使用WASD移动,鼠标瞄准射击,空格键发射导弹</p>
|
| 76 |
+
<button id="start-button">开始游戏</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
</div>
|
| 78 |
+
|
| 79 |
+
<div id="game-over">
|
| 80 |
+
<h1 class="text-4xl font-bold mb-4">游戏结束</h1>
|
| 81 |
+
<p class="text-xl mb-6" id="final-score">得分: 0</p>
|
| 82 |
+
<button id="restart-button">再来一局</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
</div>
|
| 84 |
+
|
| 85 |
+
<div id="hud">
|
| 86 |
+
<div>得分: <span id="score">0</span></div>
|
| 87 |
+
<div>生命值: <span id="health">100</span>%</div>
|
| 88 |
+
<div>导弹: <span id="missiles">5</span></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
</div>
|
| 90 |
+
|
| 91 |
+
<div id="crosshair">
|
| 92 |
+
<svg width="20" height="20" viewBox="0 0 20 20">
|
| 93 |
+
<line x1="10" y1="0" x2="10" y2="6" stroke="white" stroke-width="2"/>
|
| 94 |
+
<line x1="10" y1="14" x2="10" y2="20" stroke="white" stroke-width="2"/>
|
| 95 |
+
<line x1="0" y1="10" x2="6" y2="10" stroke="white" stroke-width="2"/>
|
| 96 |
+
<line x1="14" y1="10" x2="20" y2="10" stroke="white" stroke-width="2"/>
|
| 97 |
+
</svg>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
</div>
|
| 99 |
+
</div>
|
| 100 |
|
| 101 |
+
<script>
|
| 102 |
+
// 游戏状态
|
| 103 |
+
const gameState = {
|
| 104 |
+
score: 0,
|
| 105 |
+
health: 100,
|
| 106 |
+
missiles: 5,
|
| 107 |
+
isGameOver: false,
|
| 108 |
+
isGameStarted: false,
|
| 109 |
+
enemies: [],
|
| 110 |
+
bullets: [],
|
| 111 |
+
missiles: [],
|
| 112 |
+
enemySpawnInterval: null,
|
| 113 |
+
lastBulletTime: 0,
|
| 114 |
+
bulletCooldown: 100 // 毫秒
|
| 115 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
|
| 117 |
+
// 初始化Three.js场景
|
| 118 |
+
let scene, camera, renderer, controls;
|
| 119 |
+
let player, playerVelocity = { x: 0, y: 0, z: 0 };
|
| 120 |
+
const keys = {};
|
| 121 |
+
|
| 122 |
+
// DOM元素
|
| 123 |
+
const startScreen = document.getElementById('start-screen');
|
| 124 |
+
const gameOverScreen = document.getElementById('game-over');
|
| 125 |
+
const startButton = document.getElementById('start-button');
|
| 126 |
+
const restartButton = document.getElementById('restart-button');
|
| 127 |
+
const scoreDisplay = document.getElementById('score');
|
| 128 |
+
const healthDisplay = document.getElementById('health');
|
| 129 |
+
const missilesDisplay = document.getElementById('missiles');
|
| 130 |
+
const finalScoreDisplay = document.getElementById('final-score');
|
| 131 |
+
|
| 132 |
+
// 事件监听
|
| 133 |
+
startButton.addEventListener('click', startGame);
|
| 134 |
+
restartButton.addEventListener('click', restartGame);
|
| 135 |
+
document.addEventListener('keydown', (e) => keys[e.code] = true);
|
| 136 |
+
document.addEventListener('keyup', (e) => keys[e.code] = false);
|
| 137 |
+
document.addEventListener('click', shoot);
|
| 138 |
+
document.addEventListener('keydown', (e) => {
|
| 139 |
+
if (e.code === 'Space' && gameState.missiles > 0) {
|
| 140 |
+
fireMissile();
|
| 141 |
+
}
|
| 142 |
+
});
|
| 143 |
+
|
| 144 |
+
// 初始化游戏
|
| 145 |
+
function init() {
|
| 146 |
+
// 创建场景
|
| 147 |
+
scene = new THREE.Scene();
|
| 148 |
+
scene.background = new THREE.Color(0x87CEEB); // 天空蓝
|
| 149 |
+
|
| 150 |
+
// 添加光照
|
| 151 |
+
const ambientLight = new THREE.AmbientLight(0x404040);
|
| 152 |
+
scene.add(ambientLight);
|
| 153 |
+
|
| 154 |
+
const directionalLight = new THREE.DirectionalLight(0xffffff, 1);
|
| 155 |
+
directionalLight.position.set(1, 1, 1);
|
| 156 |
+
scene.add(directionalLight);
|
| 157 |
+
|
| 158 |
+
// 创建相机
|
| 159 |
+
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
|
| 160 |
+
camera.position.y = 5;
|
| 161 |
+
|
| 162 |
+
// 创建渲染器
|
| 163 |
+
renderer = new THREE.WebGLRenderer({ antialias: true });
|
| 164 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
| 165 |
+
document.getElementById('game-container').appendChild(renderer.domElement);
|
| 166 |
+
|
| 167 |
+
// 添加云朵
|
| 168 |
+
addClouds();
|
| 169 |
+
|
| 170 |
+
// 添加地面
|
| 171 |
+
addGround();
|
| 172 |
+
|
| 173 |
+
// 创建玩家飞机
|
| 174 |
+
createPlayer();
|
| 175 |
+
|
| 176 |
+
// 窗口大小调整处理
|
| 177 |
+
window.addEventListener('resize', () => {
|
| 178 |
+
camera.aspect = window.innerWidth / window.innerHeight;
|
| 179 |
+
camera.updateProjectionMatrix();
|
| 180 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
| 181 |
+
});
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
// 创建玩家飞机
|
| 185 |
+
function createPlayer() {
|
| 186 |
+
const geometry = new THREE.BoxGeometry(2, 0.5, 3);
|
| 187 |
+
const material = new THREE.MeshPhongMaterial({ color: 0x003366 });
|
| 188 |
+
player = new THREE.Mesh(geometry, material);
|
| 189 |
+
player.position.y = 5;
|
| 190 |
+
player.position.z = 10;
|
| 191 |
+
scene.add(player);
|
| 192 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
|
| 194 |
+
// 添加地面
|
| 195 |
+
function addGround() {
|
| 196 |
+
const groundGeometry = new THREE.PlaneGeometry(500, 500);
|
| 197 |
+
const groundMaterial = new THREE.MeshStandardMaterial({
|
| 198 |
+
color: 0x228B22, // 绿色地面
|
| 199 |
+
side: THREE.DoubleSide
|
| 200 |
+
});
|
| 201 |
+
const ground = new THREE.Mesh(groundGeometry, groundMaterial);
|
| 202 |
+
ground.rotation.x = -Math.PI / 2;
|
| 203 |
+
ground.position.y = -1;
|
| 204 |
+
scene.add(ground);
|
| 205 |
+
|
| 206 |
+
// 添加一些地面细节
|
| 207 |
+
for (let i = 0; i < 50; i++) {
|
| 208 |
+
const tree = createTree();
|
| 209 |
+
tree.position.x = Math.random() * 400 - 200;
|
| 210 |
+
tree.position.z = Math.random() * 400 - 200;
|
| 211 |
+
scene.add(tree);
|
| 212 |
+
}
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
// 创建树木
|
| 216 |
+
function createTree() {
|
| 217 |
+
const group = new THREE.Group();
|
| 218 |
+
|
| 219 |
+
// 树干
|
| 220 |
+
const trunkGeometry = new THREE.CylinderGeometry(0.2, 0.3, 2, 8);
|
| 221 |
+
const trunkMaterial = new THREE.MeshStandardMaterial({ color: 0x8B4513 });
|
| 222 |
+
const trunk = new THREE.Mesh(trunkGeometry, trunkMaterial);
|
| 223 |
+
trunk.position.y = 1;
|
| 224 |
+
group.add(trunk);
|
| 225 |
+
|
| 226 |
+
// 树叶
|
| 227 |
+
const leavesGeometry = new THREE.ConeGeometry(1.5, 3, 8);
|
| 228 |
+
const leavesMaterial = new THREE.MeshStandardMaterial({ color: 0x006400 });
|
| 229 |
+
const leaves = new THREE.Mesh(leavesGeometry, leavesMaterial);
|
| 230 |
+
leaves.position.y = 2.5;
|
| 231 |
+
group.add(leaves);
|
| 232 |
+
|
| 233 |
+
return group;
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
// 添加云朵
|
| 237 |
+
function addClouds() {
|
| 238 |
+
for (let i = 0; i < 30; i++) {
|
| 239 |
+
const cloud = createCloud();
|
| 240 |
+
cloud.position.x = Math.random() * 400 - 200;
|
| 241 |
+
cloud.position.y = Math.random() * 50 + 30;
|
| 242 |
+
cloud.position.z = Math.random() * 400 - 200;
|
| 243 |
+
scene.add(cloud);
|
| 244 |
+
}
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
// 创建云朵
|
| 248 |
+
function createCloud() {
|
| 249 |
+
const group = new THREE.Group();
|
| 250 |
+
|
| 251 |
+
const cloudMaterial = new THREE.MeshStandardMaterial({
|
| 252 |
+
color: 0xFFFFFF,
|
| 253 |
+
flatShading: true
|
| 254 |
+
});
|
| 255 |
+
|
| 256 |
+
// 多个球体组合成云朵形状
|
| 257 |
+
for (let i = 0; i < 4; i++) {
|
| 258 |
+
const size = Math.random() * 2 + 2;
|
| 259 |
+
const sphereGeometry = new THREE.SphereGeometry(size, 8, 8);
|
| 260 |
+
const sphere = new THREE.Mesh(sphereGeometry, cloudMaterial);
|
| 261 |
|
| 262 |
+
sphere.position.x = Math.random() * 4 - 2;
|
| 263 |
+
sphere.position.y = Math.random() * 2 - 1;
|
| 264 |
+
sphere.position.z = Math.random() * 2 - 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 265 |
|
| 266 |
+
group.add(sphere);
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
return group;
|
| 270 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
|
| 272 |
+
// 创建敌人飞机
|
| 273 |
+
function createEnemy() {
|
| 274 |
+
const geometry = new THREE.BoxGeometry(2, 0.5, 3);
|
| 275 |
+
const material = new THREE.MeshPhongMaterial({ color: 0xB22222 });
|
| 276 |
+
const enemy = new THREE.Mesh(geometry, material);
|
| 277 |
+
|
| 278 |
+
// 随机位置生成敌人
|
| 279 |
+
enemy.position.x = Math.random() * 200 - 100;
|
| 280 |
+
enemy.position.y = Math.random() * 20 + 5;
|
| 281 |
+
enemy.position.z = Math.random() * 100 - 150;
|
| 282 |
+
|
| 283 |
+
// 添加随机速度
|
| 284 |
+
enemy.userData = {
|
| 285 |
+
speed: Math.random() * 2 + 1,
|
| 286 |
+
health: 30
|
| 287 |
+
};
|
| 288 |
+
|
| 289 |
+
scene.add(enemy);
|
| 290 |
+
gameState.enemies.push(enemy);
|
| 291 |
+
|
| 292 |
+
return enemy;
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
// 射击函数
|
| 296 |
+
function shoot() {
|
| 297 |
+
if (!gameState.isGameStarted || gameState.isGameOver) return;
|
| 298 |
+
|
| 299 |
+
const now = Date.now();
|
| 300 |
+
if (now - gameState.lastBulletTime < gameState.bulletCooldown) return;
|
| 301 |
+
|
| 302 |
+
gameState.lastBulletTime = now;
|
| 303 |
+
|
| 304 |
+
// 创建子弹
|
| 305 |
+
const bulletGeometry = new THREE.SphereGeometry(0.1, 8, 8);
|
| 306 |
+
const bulletMaterial = new THREE.MeshBasicMaterial({ color: 0xFFD700 });
|
| 307 |
+
const bullet = new THREE.Mesh(bulletGeometry, bulletMaterial);
|
| 308 |
+
|
| 309 |
+
// 从飞机前方发射
|
| 310 |
+
bullet.position.copy(player.position);
|
| 311 |
+
bullet.position.z -= 2;
|
| 312 |
+
|
| 313 |
+
// 设置子弹方向和速度
|
| 314 |
+
bullet.userData = {
|
| 315 |
+
direction: new THREE.Vector3(0, 0, -1),
|
| 316 |
+
speed: 10
|
| 317 |
+
};
|
| 318 |
+
|
| 319 |
+
scene.add(bullet);
|
| 320 |
+
gameState.bullets.push(bullet);
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
// 发射导弹
|
| 324 |
+
function fireMissile() {
|
| 325 |
+
if (!gameState.isGameStarted || gameState.isGameOver || gameState.missiles <= 0) return;
|
| 326 |
+
|
| 327 |
+
gameState.missiles--;
|
| 328 |
+
updateHUD();
|
| 329 |
+
|
| 330 |
+
// 创建导弹
|
| 331 |
+
const missileGeometry = new THREE.ConeGeometry(0.3, 1, 8);
|
| 332 |
+
const missileMaterial = new THREE.MeshPhongMaterial({ color: 0xFF4500 });
|
| 333 |
+
const missile = new THREE.Mesh(missileGeometry, missileMaterial);
|
| 334 |
+
|
| 335 |
+
// 从飞机前方发射
|
| 336 |
+
missile.position.copy(player.position);
|
| 337 |
+
missile.position.z -= 2;
|
| 338 |
+
missile.rotation.x = Math.PI / 2;
|
| 339 |
+
|
| 340 |
+
// 设置导弹方向和速度
|
| 341 |
+
missile.userData = {
|
| 342 |
+
direction: new THREE.Vector3(0, 0, -1),
|
| 343 |
+
speed: 6,
|
| 344 |
+
damage: 50,
|
| 345 |
+
isMissile: true
|
| 346 |
+
};
|
| 347 |
+
|
| 348 |
+
scene.add(missile);
|
| 349 |
+
gameState.missiles.push(missile);
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
// 更新HUD
|
| 353 |
+
function updateHUD() {
|
| 354 |
+
scoreDisplay.textContent = gameState.score;
|
| 355 |
+
healthDisplay.textContent = gameState.health;
|
| 356 |
+
missilesDisplay.textContent = gameState.missiles;
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
// 开始游戏
|
| 360 |
+
function startGame() {
|
| 361 |
+
gameState.isGameStarted = true;
|
| 362 |
+
startScreen.style.display = 'none';
|
| 363 |
+
|
| 364 |
+
// 锁定鼠标指针
|
| 365 |
+
controls = new THREE.PointerLockControls(camera, document.body);
|
| 366 |
+
|
| 367 |
+
// 添加点击事件来锁定指针
|
| 368 |
+
const gameContainer = document.getElementById('game-container');
|
| 369 |
+
const pointerLockChange = () => {
|
| 370 |
+
if (document.pointerLockElement === gameContainer ||
|
| 371 |
+
document.mozPointerLockElement === gameContainer ||
|
| 372 |
+
document.webkitPointerLockElement === gameContainer) {
|
| 373 |
+
controls.enabled = true;
|
| 374 |
+
} else {
|
| 375 |
+
controls.enabled = false;
|
| 376 |
+
}
|
| 377 |
+
};
|
| 378 |
+
|
| 379 |
+
document.addEventListener('pointerlockchange', pointerLockChange, false);
|
| 380 |
+
document.addEventListener('mozpointerlockchange', pointerLockChange, false);
|
| 381 |
+
document.addEventListener('webkitpointerlockchange', pointerLockChange, false);
|
| 382 |
+
|
| 383 |
+
gameContainer.requestPointerLock = gameContainer.requestPointerLock ||
|
| 384 |
+
gameContainer.mozRequestPointerLock ||
|
| 385 |
+
gameContainer.webkitRequestPointerLock;
|
| 386 |
+
|
| 387 |
+
gameContainer.requestPointerLock();
|
| 388 |
+
|
| 389 |
+
// 开始生成敌人
|
| 390 |
+
gameState.enemySpawnInterval = setInterval(() => {
|
| 391 |
+
if (!gameState.isGameOver) {
|
| 392 |
+
createEnemy();
|
| 393 |
+
}
|
| 394 |
+
}, 2000);
|
| 395 |
+
|
| 396 |
+
// 开始游戏循环
|
| 397 |
+
animate();
|
| 398 |
+
}
|
| 399 |
+
|
| 400 |
+
// 游戏结束
|
| 401 |
+
function gameOver() {
|
| 402 |
+
gameState.isGameOver = true;
|
| 403 |
+
clearInterval(gameState.enemySpawnInterval);
|
| 404 |
+
gameOverScreen.style.display = 'flex';
|
| 405 |
+
finalScoreDisplay.textContent = `得分: ${gameState.score}`;
|
| 406 |
+
}
|
| 407 |
|
| 408 |
+
// 重新开始游戏
|
| 409 |
+
function restartGame() {
|
| 410 |
+
gameState.score = 0;
|
| 411 |
+
gameState.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 412 |
</html>
|