three实现等距(Isometric)偏柔和画风的三维小镇生存游戏代码

代码语言:html

所属分类:游戏

代码描述:three实现等距(Isometric)偏柔和画风的三维小镇生存游戏代码,砍柴赚钱:前往树林用斧头砍树(左键 / 空格),收集掉落的木柴,前往东南侧的**【收购摊位】**按 E 卖钱。树木过一段时间会再生。 打架劫掠:攻击路上的村民或治安官(左键 / 空格),击败后会掉落金币袋和食物/急救包;注意攻击行为会触发附近治安官追击! 潜入偷窃:小镇里有 5 栋可进入的房屋,走到门前按 E 或直接穿门而入,屋顶会自动掀开隐藏以显示室内家具和宝箱/保险柜!按 Shift 或 C 蹲伏潜行可缩小被屋主视野发现的概率;

代码标签: three 等距(Isometric)偏柔和 画风 三维 小镇 生存 游戏 代码

下面为部分代码预览,完整代码请点击下载或在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>橡木镇生存物语 // Isometric 3D Town Survival</title>
<style>
  * { box-sizing: border-box; user-select: none; }
  html, body {
    margin: 0; padding: 0; width: 100%; height: 100%;
    overflow: hidden; background: #5b6340;
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    color: #f4efe2;
  }
  #gameContainer { position: fixed; inset: 0; }
  canvas { display: block; width: 100%; height: 100%; }

  /* HUD */
  #hud {
    position: fixed; inset: 0; pointer-events: none;
    padding: 14px 18px;
    display: flex; flex-direction: column; justify-content: space-between;
    z-index: 10;
  }
  .hud-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
  .card {
    background: rgba(34, 38, 28, 0.82);
    border: 2px solid rgba(224, 212, 178, 0.35);
    border-radius: 10px;
    padding: 10px 14px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
    backdrop-filter: blur(4px);
    pointer-events: auto;
  }
  .status-card { min-width: 245px; }
  .bar-wrap { margin-bottom: 6px; }
  .bar-label {
    display: flex; justify-content: space-between;
    font-size: 11px; font-weight: 700; color: #dcd4bc; margin-bottom: 2px;
  }
  .bar-bg {
    height: 8px; background: rgba(0,0,0,0.45);
    border-radius: 4px; overflow: hidden;
  }
  .bar-fill { height: 100%; width: 100%; transition: width 0.12s; }
  #hpFill { background: linear-gradient(90deg, #c94a38, #6eb356); }
  #hungerFill { background: linear-gradient(90deg, #b86a2e, #e3aa4b); }
  #stamFill { background: linear-gradient(90deg, #4b8da6, #78c7d4); }

  .money-row {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 8px; padding-top: 7px;
    border-top: 1px solid rgba(255,255,255,0.12);
    font-size: 15px; font-weight: 800; color: #f6d365;
  }
  .gear-row {
    display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; font-size: 11px;
  }
  .tag {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    padding: 2px 7px; border-radius: 5px; color: #e8e0c8; font-weight: 700;
  }
  .tag.active { background: rgba(110, 179, 86, 0.25); border-color: #82cc6a; color: #c8f5b8; }

  .right-card { text-align: right; min-width: 210px; }
  .day-time { font-size: 17px; font-weight: 800; color: #f7eed5; }
  .alert-badge {
    display: inline-block; margin-top: 5px; padding: 3px 10px;
    border-radius: 5px; font-size: 12px; font-weight: 800; letter-spacing: 0.5px;
    background: rgba(102, 166, 86, 0.25); border: 1px solid #7fc26b; color: #c7f0ba;
  }
  .alert-badge.sneak { background: rgba(88, 148, 176, 0.3); border-color: #7cc5e3; color: #bce9fa; }
  .alert-badge.trespass { background: rgba(214, 152, 52, 0.32); border-color: #f0b34d; color: #ffe1a8; }
  .alert-badge.wanted { background: rgba(204, 58, 48, 0.42); border-color: #ff6254; color: #ffd2ce; animation: pulse 0.8s infinite alternate; }
  @keyframes pulse { from { opacity: 0.75; } to { opacity: 1; } }

  .mini-btns { margin-top: 8px; display: flex; gap: 6px; justify-content: flex-end; }
  .btn-sm {
    background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.24);
    color: #efe8d5; font-size: 11px; font-weight: 700; padding: 4px 8px;
    border-radius: 5px; cursor: pointer;
  }
  .btn-sm:hover { background: rgba(255,255,255,0.2); }

  /* Bottom Hotbar & Controls */
  .hud-bottom {
    display: flex; justify-content: space-between; align-items: flex-end; gap: 12px;
  }
  .hotbar {
    display: flex; gap: 8px; pointer-events: auto;
  }
  .slot {
    background: rgba(34, 38, 28, 0.86);
    border: 2px solid rgba(224, 212, 178, 0.35);
    border-radius: 8px; padding: 7px 11px; min-width: 82px;
    text-align: center; cursor: pointer; transition: transform 0.1s, border-color 0.1s;
  }
  .slot:hover { transform: translateY(-2px); border-color: #f6d365; }
  .slot-key { font-size: 10px; color: #b8af96; font-weight: 700; }
  .slot-name { font-size: 12px; font-weight: 800; color: #f4efe2; margin: 2px 0; }
  .slot-cnt { font-size: 12px; font-weight: 800; color: #f6d365; }

  .hint-box {
    background: rgba(28, 32, 24, 0.78);
    border: 1px solid rgba(224, 212, 178, 0.25);
    border-radius: 8px; padding: 8px 12px; font-size: 12px; color: #ddd5be;
    line-height: 1.5;
  }
  .k {
    display: inline-block; background: rgba(255,255,255,0.14);
    border: 1px solid rgba(255,255,255,0.28); border-radius: 4px;
    padding: 0 5px; font-size: 11px; font-weight: 800; color: #ffe7a8;
  }

  /* World Interact Prompt */
  #interactPrompt {
    position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%);
    background: rgba(28, 32, 22, 0.9); border: 2px solid #f6d365;
    color: #fff3cc; padding: 7px 16px; border-radius: 20px;
    font-size: 13px; font-weight: 800; pointer-events: none;
    display: none; z-index: 15; box-shadow: 0 4px 14px rgba(0,0,0,0.45);
  }

  /* Floating Text Layer */
  #floatLayer {
    position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 12;
  }
  .float-msg {
    position: absolute; font-size: 13px; font-weight: 900;
    text-shadow: 0 2px 4px rgba(0,0,0,0.85);
    transform: translate(-50%, -50%);
    white-space: nowrap;
  }

  /* Modals (Shop / Title / GameOver) */
  .overlay {
    position: fixed; inset: 0; background: rgba(20, 24, 16, 0.72);
    display: flex; align-items: center; justify-content: center;
    z-index: 30; padding: 20px; backdrop-filter: blur(4px);
  }
  .overlay.hidden { display: none; }
  .modal {
    max-width: 500px; width: 100%;
    background: #2b3023; border: 2px solid #c9ba93;
    border-radius: 14px; padding: 24px 28px; text-align: center;
    box-shadow: 0 18px 50px rgba(0,0,0,0.6);
  }
  .modal h1 { margin: 0 0 6px; font-size: 26px; color: #f6e7c1; }
  .modal p { margin: 0 0 18px; font-size: 13px; color: #cfc7ae; line-height: 1.6; }
  .btn-main {
    background: linear-gradient(135deg, #c9863a, #9c563a);
    border: 1px solid #f3d299; color: #fffaf0;
    font-size: 15px; font-weight: 800; padding: 11px 28px;
    border-radius: 8px; cursor: pointer;
  }
  .btn-main:hover { filter: brightness(1.1); }
  .shop-list { text-align: left; display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
  .shop-item {
    display: flex; justify-content: space-between; align-items: center;
    background: rgba(0,0,0,0.25); padding: 9px 12px; border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.12);
  }
  .shop-item strong { color: #f6e7c1; font-size: 13px; display: block; }
  .shop-item span { font-size: 11px; color: #b8b099; }
  .btn-buy {
    background: #5b8c4a; border: 1px solid #8fd177; color: #fff;
    font-weight: 800; font-size: 12px; padding: 6.........完整代码请登录后点击上方下载按钮下载查看

网友评论0