three实现三维末日小岛丧尸塔防地形游戏代码

代码语言:html

所属分类:其他

代码由gemini-4-hydrogen ai生成,可能有错误,仅供参考:点击查看提示词

代码描述:three实现三维末日小岛丧尸塔防地形游戏代码

代码标签: three 三维 末日 小岛 丧尸 塔防 地形 游戏 代码

下面为部分代码预览,完整代码请点击下载或在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>三维荒地海边小屋保卫战 - 地形改造塔防</title>
  <style>
    * { margin: 0; padding: 0; box-sizing: border-box; user-select: none; }
    body { overflow: hidden; background: #8faab5; font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif; }
    canvas { display: block; cursor: crosshair; }

    /* 顶部状态栏 */
    #top-bar {
      position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
      display: flex; gap: 14px; align-items: center; z-index: 10;
      background: rgba(22, 26, 30, 0.84);
      border: 1px solid rgba(255, 190, 90, 0.45);
      backdrop-filter: blur(8px);
      padding: 10px 20px; border-radius: 10px; color: #f2efe9;
      box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
    }
    .stat-box { display: flex; flex-direction: column; min-width: 115px; }
    .stat-label { font-size: 11px; color: #b5afa4; letter-spacing: 0.5px; }
    .stat-val { font-size: 18px; font-weight: bold; color: #ffd166; }
    .hp-wrap { width: 150px; height: 10px; background: rgba(255,255,255,0.15); border-radius: 5px; overflow: hidden; margin-top: 4px; }
    #house-hp-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #ef476f, #06d6a0); transition: width 0.2s; }

    #wave-btn {
      padding: 10px 20px; font-size: 15px; font-weight: bold;
      color: #1a140b; background: linear-gradient(135deg, #ffb703, #fb8500);
      border: none; border-radius: 8px; cursor: pointer;
      box-shadow: 0 0 18px rgba(251, 133, 0, 0.5);
      transition: transform 0.15s, filter 0.15s;
    }
    #wave-btn:hover:not(:disabled) { transform: scale(1.05); filter: brightness(1.1); }
    #wave-btn:disabled { background: #4a4e54; color: #9aa0a6; cursor: not-allowed; box-shadow: none; }

    /* 左上角操作提示 */
    #help-panel {
      position: fixed; left: 16px; top: 16px; z-index: 10;
      background: rgba(20, 24, 28, 0.78); border: 1px solid rgba(255,255,255,0.18);
      color: #e0ddd5; padding: 10px 14px; border-radius: 8px; font-size: 12px; line-height: 1.65;
      pointer-events: none;
    }
    #help-panel b { color: #ffd166; }

    /* 右上角提示反馈 */
    #toast-box {
      position: fixed; right: 18px; top: 18px; z-index: 10;
      display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
      pointer-events: none;
    }
    .toast {
      background: rgba(20, 26, 30, 0.85); color: #fff; padding: 7px 14px;
      border-left: 3px solid #06d6a0; border-radius: 4px; font-size: 13px;
      box-shadow: 0 3px 12px rgba(0,0,0,0.3);
    }

    /* 底部建造与地形工具栏 */
    #toolbar {
      position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
      display: flex; gap: 8px; align-items: center; z-index: 10;
      background: rgba(22, 26, 30, 0.88);
      border: 1px solid rgba(255, 255, 255, 0.2);
      backdrop-filter: blur(8px);
      padding: 10px 14px; border-radius: 12px;
      box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
    }
    .tool-btn {
      position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
      min-width: 86px; padding: 8px 10px; border-radius: 8px;
      background: rgba(255, 255, 255, 0.07); border: 2px solid transparent;
      color: #e8e6e1; cursor: pointer; transition: all 0.15s;
    }
    .tool-btn:hover { background: rgba(255, 255, 255, 0.14); }
    .tool-btn.active {
      background: rgba(255, 183, 3, 0.22);
      border-color: #ffb703; color: #fff;
      box-shadow: 0 0 14px rgba(255, 183, 3, 0.35);
    }
    .tool-key {
      position: absolute; top: 3px; left: 6px; font-size: 10px; color: #99a3ad;
    }
    .tool-icon { font-size: 20px; margin-bottom: 2px; }
    .tool-name { font-size: 12px; font-weight: 600; }
    .tool-cost { font-size: 11px; color: #ffd166; margin-top: 2px; }
    .divider { width: 1px; height: 48px; background: rgba(255,255,255,0.18); margin: 0 4px; }

    #brush-size-box {
      display: flex; flex-direction: column; gap: 4px; padding: 0 6px; color: #ccc; font-size: 11px;
    }
    #brush-size-box select {
      background: #2c3136; color: #fff; border: 1px solid #555; border-radius: 4px; padding: 3px 6px; font-size: 12px;
    }

    /* 游戏结束弹窗 */
    #game-over {
      position: fixed; inset: 0; z-index: 30; display: none;
      background: rgba(15, 12, 12, 0.85); backdrop-filter: blur(6px);
      flex-direction: column; align-items: center; justify-content: center; color: #fff; text-align: center;
    }
    #game-over h1 { font-size: 44px; color: #ff4d6d; margin-bottom: 12px; }
    #game-over p { font-size: 17px; color: #ddd; margin-bottom: 24px; }
    #restart-btn {
      padding: 14px 40px; font-size: 18px; font-weight: bold;
      background: #06d6a0; color: #0b2019; border: none; border-radius: 30px; cursor: pointer;
    }
  </style>

  <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="top-bar">
    <div class="stat-box">
      <span class="stat-label">木屋耐久度 (<span id="house-hp-text">500/500</span>)</span>
      <div class="hp-wrap"><div id="house-hp-fill"></div></div>
    </div>
    <div class="stat-box">
      <span class="stat-label">废料资源</span>
  .........完整代码请登录后点击上方下载按钮下载查看

网友评论0