three实现三维机甲大战怪兽游戏代码
代码语言:html
所属分类:其他
代码由gemini-4 ai生成,可能有错误,仅供参考:点击查看提示词
代码描述:三维机甲大战怪兽游戏
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>泰坦机甲:白天城市保卫战 (Three.js)</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; }
body { overflow: hidden; background: #87ceeb; font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif; }
canvas { display: block; }
/* HUD 层 */
#hud {
position: fixed; inset: 0; pointer-events: none; z-index: 10;
display: none;
}
/* 驾驶舱全息边框装饰 (仅驾驶舱模式显示) */
#cockpit-overlay {
position: fixed; inset: 0; pointer-events: none; display: none;
background: radial-gradient(circle at center, transparent 58%, rgba(0, 25, 45, 0.55) 100%);
box-shadow: inset 0 0 80px rgba(0, 180, 255, 0.2);
}
.cockpit-line {
position: absolute; border: 1px solid rgba(0, 225, 255, 0.35);
}
.cockpit-arc-l {
left: 12%; top: 18%; width: 120px; height: 64%;
border-right: none; border-radius: 60px 0 0 60px;
}
.cockpit-arc-r {
right: 12%; top: 18%; width: 120px; height: 64%;
border-left: none; border-radius: 0 60px 60px 0;
}
/* 准星 */
#crosshair {
position: absolute; left: 50%; top: 50%;
transform: translate(-50%, -50%);
width: 44px; height: 44px;
}
#crosshair::before, #crosshair::after {
content: ''; position: absolute; background: rgba(0, 255, 230, 0.9);
box-shadow: 0 0 8px rgba(0, 255, 230, 0.8);
}
#crosshair::before { left: 21px; top: 4px; width: 2px; height: 36px; }
#crosshair::after { top: 21px; left: 4px; height: 2px; width: 36px; }
.cross-ring {
position: absolute; inset: 6px; border: 2px solid rgba(0, 255, 230, 0.75);
border-radius: 50%;
}
/* 状态面板 */
.panel {
position: absolute; background: rgba(10, 22, 36, 0.72);
border: 1px solid rgba(0, 210, 255, 0.5);
backdrop-filter: blur(6px);
color: #e6f7ff; padding: 12px 16px; border-radius: 6px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}
#mech-status { left: 20px; bottom: 20px; width: 290px; }
#controls-help { left: 20px; top: 20px; font-size: 13px; line-height: 1.65; }
#controls-help b { color: #00eaff; }
#kaiju-status {
top: 20px; left: 50%; transform: translateX(-50%);
width: 420px; text-align: center;
}
#view-badge {
right: 20px; top: 20px; font-weight: bold; color: #00ffcc;
font-size: 14px; letter-spacing: 1px;
}
#weapons-panel {
right: 20px; bottom: 20px; width: 250px; text-align: right;
}
.bar-bg {
width: 100%; height: 12px; background: rgba(255, 255, 255, 0.14);
border-radius: 6px; overflow: hidden; margin-top: 6px;
}
.bar-fill { height: 100%; transition: width 0.15s ease; }
#mech-hp-bar { background: linear-gradient(90deg, #00c6ff, #00ff9d); width: 100%; }
#kaiju-hp-bar { background: linear-gradient(90deg, #ff3b30, #ff9500); width: 100%; }
#cannon-cd-bar { background: #00eaff; width: 100%; }
#punch-cd-bar { background: #ffae00; width: 100%; }
/* 警告提示 */
#warning-banner {
position: absolute; top: 110px; left: 50%; transform: translateX(-50%);
background: rgba(255, 30, 30, 0.85); color: #fff;
padding: 8px 26px; font-weight: bold; font-size: 18px;
border: 2px solid #ffaaaa; border-radius: 4px; letter-spacing: 2px;
display: none; animation: pulse 0.4s infinite alternate;
}
@keyframes pulse { from { opacity: 0.6; transform: translateX(-50%) scale(0.98); } to { opacity: 1; transform: translateX(-50%) scale(1.03); } }
#damage-flash {
position: fixed; inset: 0; pointer-events: none; z-index: 9;
background: radial-gradient(circle, transparent 40%, rgba(255, 40, 0, 0.65) 100%);
opacity: 0; transition: opacity 0.15s;
}
/* 开始/暂停/结束 菜单 */
#overlay-menu {
position: fixed; inset: 0; z-index: 20;
background: linear-gradient(135deg, rgba(10, 25, 47, 0.86), rgba(15, 45, 70, 0.78));
display: flex; flex-direction: column; align-items: center; justify-content: center;
color: #fff; text-align: center; padding: 20px;
}
#overlay-menu h1 {
font-size: 42px; margin-bottom: 12px;
text-shadow: 0 0 25px rgba(0, 225, 255, 0.8);
letter-spacing: 3px;
}
#overlay-menu p { max-width: 620px; line-height: 1.7; color: #cde9ff; margin-bottom: 24px; font-size: 16px; }
#start-btn {
padding: 15px 46px; font-size: 20px; font-weight: bold; color: #051829;
background: linear-gradient(90deg, #00eaff, #00ffaa);
border: none; border-radius: 40px; cursor: pointer;
box-shadow: 0 0 30px rgba(0, 234, 255, 0.6);
transition: transform 0.15s, box-shadow 0.15s;
}
#start-btn:hover { transform: scale(1.06); box-shadow: 0 0 42px rgba(0, 255, 190, 0.9); }
#kill-feed {
position: absolute; right: 20px; top: 75px; text-align: right;
font-size: 13px; color: #ffe082; text-shadow: 0 1px 4px #000;
}
</style>
<!-- Import Map 引入 Three.js 及官方天空插件 -->
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.160.0/examples/jsm/"
}
}
</script>
</head>
<body>
<div id="damage-flash"></div>
<div id="hud">
<div id="cockpit-overlay">
<div class="cockpit-line cockpit-arc-l"></div>
<div class="cockpit-line cockpit-arc-r"></div>
</div>
<div id="crosshair"><div class="cross-ring"></div></div>
<div id="controls-help" class="panel">
<div><b>W A S D</b>:机甲行走 | <b>Shift</b>:推进冲刺</div>
<div><b>鼠标移动</b>:瞄准转向 | <b>V 键</b>:切换驾驶舱 / 第三人称</div>
<div><b>左键 / F</b>:发射双联等离子炮(摧毁建筑/怪兽)</div>
<div><b>右键 / E</b>:重型近战重拳 | <b>ESC</b>:释放鼠标</div>
</div>
<div id="kaiju-status" class="panel">
<div style="display:flex; justify-content:space-between; font-size:14px; font-weight:bold;">
<span id="kaiju-name">怪兽威胁:开菊巨兽 LV.1</span>
<span id.........完整代码请登录后点击上方下载按钮下载查看















网友评论0