js实现类似王者荣耀游戏代码

代码语言:html

所属分类:其他

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

代码描述:js实现类似王者荣耀游戏代码

代码标签: js 类似 王者荣耀 游戏 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!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>峡谷争锋 · RIFT CLASH</title>
<style>
  :root {
    --bg-dark: #09101a;
    --panel-bg: rgba(11, 19, 32, 0.92);
    --panel-border: #c89b3c;
    --border-dim: #463714;
    --blue-team: #2aa6ff;
    --red-team: #ff4655;
    --gold: #f0c040;
    --exp: #a855f7;
    --hp: #22c55e;
    --mp: #3b82f6;
    --warn: #ef4444;
    --text-main: #f0e6d2;
    --text-sub: #a09b8c;
  }
  * { box-sizing: border-box; user-select: none; -webkit-user-select: none; }
  html, body {
    margin: 0; padding: 0; width: 100%; height: 100%;
    overflow: hidden; background: #05080f; color: var(--text-main);
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    touch-action: none;
  }
  /* Custom Scrollbar */
  ::-webkit-scrollbar { width: 6px; height: 6px; }
  ::-webkit-scrollbar-track { background: #0a1019; }
  ::-webkit-scrollbar-thumb { background: #785a28; border-radius: 3px; }
  ::-webkit-scrollbar-thumb:hover { background: #c89b3c; }

  #game-container { position: fixed; inset: 0; width: 100%; height: 100%; }
  #webgl-canvas, #overlay-canvas {
    position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  }
  #overlay-canvas { pointer-events: none; z-index: 2; }

  /* HUD Layer */
  #hud {
    position: fixed; inset: 0; z-index: 10; pointer-events: none;
    display: none;
  }
  .hud-interactive { pointer-events: auto; }

  /* Top Bar */
  #top-bar {
    position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    display: flex; align-items: center; gap: 14px;
    background: linear-gradient(180deg, rgba(16,26,43,0.95), rgba(8,14,24,0.9));
    border: 1px solid var(--border-dim); border-bottom: 2px solid var(--panel-border);
    padding: 5px 16px; border-radius: 6px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.65);
    font-size: 13px; white-space: nowrap;
  }
  .score-blue { color: var(--blue-team); font-weight: 700; font-size: 16px; }
  .score-red { color: var(--red-team); font-weight: 700; font-size: 16px; }
  .top-sep { width: 1px; height: 18px; background: #2c384e; }
  #match-timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text-main); letter-spacing: 1px; }
  .tower-count { font-size: 12px; color: var(--text-sub); }

  #top-controls {
    position: absolute; top: 8px; right: 10px;
    display: flex; gap: 6px;
  }
  .icon-btn {
    background: var(--panel-bg); border: 1px solid #524222; color: var(--text-main);
    border-radius: 5px; padding: 6px 10px; cursor: pointer; font-size: 12px;
    transition: all 0.15s;
  }
  .icon-btn:hover { border-color: var(--panel-border); background: #172438; }

  /* Minimap */
  #minimap-wrap {
    position: absolute; right: 12px; bottom: 12px;
    width: 176px; height: 176px;
    background: #070d16; border: 2px solid var(--panel-border);
    border-radius: 6px; box-shadow: 0 0 20px rgba(0,0,0,0.8);
    overflow: hidden;
  }
  #minimap-canvas { width: 100%; height: 100%; display: block; cursor: pointer; }

  /* Bottom Center HUD */
  #bottom-hud {
    position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
    display: flex; align-items: flex-end; gap: 10px;
    transform-origin: bottom center;
  }
  .hud-panel {
    background: linear-gradient(180deg, rgba(14,23,38,0.95), rgba(8,13,22,0.96));
    border: 1px solid var(--border-dim); border-top: 2px solid var(--panel-border);
    border-radius: 6px; padding: 8px; box-shadow: 0 6px 24px rgba(0,0,0,0.75);
  }
  #hero-card {
    display: flex; align-items: center; gap: 10px; position: relative;
  }
  #hero-avatar {
    width: 54px; height: 54px; border-radius: 50%;
    border: 2px solid var(--panel-border);
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; font-weight: 800; position: relative;
    background: radial-gradient(circle, #1e3250, #0b1422);
    flex-shrink: 0;
  }
  #hero-level-badge {
    position: absolute; bottom: -3px; right: -3px;
    width: 22px; height: 22px; border-radius: 50%;
    background: #0d1624; border: 1.5px solid var(--panel-border);
    color: var(--gold); font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
  }
  #hero-stats-col { display: flex; flex-direction: column; gap: 4px; min-width: 115px; }
  #hero-name-hud { font-size: 12px; font-weight: 700; color: var(--text-main); display: flex; justify-content: space-between; }
  .stat-mini-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px;
    font-size: 11px; color: var(--text-sub);
  }
  .stat-mini-grid span b { color: var(--text-main); }

  /* Center Skills & Bars */
  #skills-panel { display: flex; flex-direction: column; gap: 6px; min-width: 320px; }
  #skills-row { display: flex; align-items: center; gap: 8px; justify-content: center; }
  .skill-slot {
    position: relative; width: 48px; height: 48px;
    border: 2px solid #5b4922; border-radius: 6px;
    background: #0b1320; cursor: pointer; overflow: visible;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.1s, border-color 0.15s;
  }
  .skill-slot.ready { border-color: var(--panel-border); }
  .skill-slot.unlearned { opacity: 0.45; filter: grayscale(0.8); }
  .skill-slot.active-ind { border-color: #38bdf8; box-shadow: 0 0 12px rgba(56,189,248,0.65); }
  .skill-slot:active { transform: scale(0.95); }
  .skill-icon-glyph { font-size: 20px; font-weight: 800; pointer-events: none; }
  .skill-key {
    position: absolute; bottom: -2px; left: 2px;
    background: rgba(5,10,18,0.9); color: var(--text-main);
    font-size: 10px; font-weight: 700; padding: 0 4px; border-radius: 3px;
    border: 1px solid #3c3420;
  }
  .skill-mana {
    position: absolute; top: 1px; right: 3px;
    font-size: 9px; color: #7dd3fc; font-weight: 700; text-shadow: 0 1px 2px #000;
  }
  .skill-cd-overlay {
    position: absolute; inset: 0; border-radius: 4px;
    display: none; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 800; color: #fff;
    text-shadow: 0 1px 4px #000; pointer-events: none;
  }
  .skill-pips {
    position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 2px;
  }
  .skill-pip { width: 5px; height: 4px; border-radius: 1px; background: #263142; }
  .skill-pip.on { background: var(--gold); }
  .skill-lvlup-btn {
    position: absolute; top: -22px; left: 50%; transform: translateX(-50%);
    width: 24px; height: 18px; border-radius: 4px;
    background: linear-gradient(180deg, #f59e0b, #b45309);
    border: 1px solid #fde68a; color: #fff; font-weight: 900; font-size: 14px;
    line-height: 14px; text-align: center; cursor: pointer;
    display: none; box-shadow: 0 0 10px rgba(245,158,11,0.8);
    animation: pulseUp 1s infinite;
  }
  @keyframes pulseUp { 0%,100%{transform:translateX(-50%) scale(1);} 50%{transform:translateX(-50%) scale(1.1);} }

  .sum-slot { width: 38px; height: 38px; }
  .sum-slot .skill-icon-glyph { font-size: 16px; }

  /* Bars */
  .bar-wrap {
    position: relative; height: 16px; background: #070c14;
    border: 1px solid #2b384d; border-radius: 3px; overflow: hidden;
  }
  .bar-fill { height: 100%; transition: width 0.08s linear; }
  #hp-fill { background: linear-gradient(90deg, #16a34a, #4ade80); }
  #mp-fill { background: linear-gradient(90deg, #1d4ed8, #60a5fa); }
  #exp-wrap { height: 6px; border-color: #2f2344; }
  #exp-fill { background: linear-gradient(90deg, #7e22ce, #c084fc); }
  .bar-text {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000;
  }

  /* Items & Gold Panel */
  #items-panel { display: flex; flex-direction: column; gap: 5px; }
  #items-grid { display: grid; grid-template-columns: repeat(3, 34px); gap: 4px; }
  .item-slot {
    width: 34px; height: 34px; background: #070d16;
    border: 1px solid #3c3422; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; position: relative; cursor: pointer;
  }
  .item-slot.filled { border-color: var(--panel-border); background: #132036; }
  #gold-kda-row {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 11px; gap: 8px;
  }
  #gold-text { color: var(--gold); font-weight: 700; cursor: pointer; }
  #kda-cs-text { color: var(--text-sub); font-weight: 600; }

  /* Recall & Status Banners */
  #recall-bar-wrap {
    position: fixed; bottom: 168px; left: 50%; transform: translateX(-50%);
    width: 240px; background: rgba(9,16,28,0.92);
    border: 1px solid #38bdf8; border-radius: 6px; padding: 6px 10px;
    display: none; z-index: 12; text-align: center;
  }
  #recall-fill { height: 8px; background: linear-gradient(90deg, #0284c7, #67e8f9); border-radius: 4px; width: 0%; }

  #kill-feed {
    position: fixed; top: 52px; left: 50%; transform: translateX(-50%);
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    pointer-events: none; z-index: 11;
  }
  .kill-banner {
    background: rgba(10,16,28,0.88); border: 1px solid var(--panel-border);
    padding: 4px 14px; border-radius: 4px; font-size: 12px; font-weight: 700;
    animation: fadeSlide 3.2s forwards;
  }
  @keyframes fadeSlide { 0%{opacity:0;transform:translateY(-8px);} 10%{opacity:1;transform:translateY(0);} 80%{opacity:1;} 100%{opacity:0;} }

  #skill-tooltip {
    position: fixed; bottom: 155px; left: 50%; transform: translateX(-50%);
    max-width: 300px; background: rgba(8,14,24,0.96);
    border: 1px solid var(--panel-border); border-radius: 6px; padding: 8px 12px;
    font-size: 12px; line-height: 1.45; display: none; z-index: 25; pointer-events: none;
    box-shadow: 0 8px 24px rgba(0,0,0,0.8);
  }

  /* Death Overlay */
  #death-overlay {
    position: fixed; inset: 0; background: rgba(10, 14, 22, 0.45);
    display: none; align-items: center; justify-content: center;
    z-index: 14; pointer-events: none;
  }
  #death-box {
    background: rgba(12,18,30,0.92); border: 2px solid var(--red-team);
    padding: 18px 34px; border-radius: 10px; text-align: center;
  }
  #death-timer { font-size: 38px; font-weight: 800; color: var(--red-team); }

  /* Overlays: Hero Select, Shop, Scoreboard, Pause, End */
  .modal-backdrop {
    position: fixed; inset: 0; background: rgba(4, 8, 15, 0.84);
    backdrop-filter: blur(5px);
    display: none; align-items: center; justify-content: center;
    z-index: 30; padding: 16px;
  }
  .modal-card {
    background: linear-gradient(180deg, #101b2e, #09101c);
    border: 1px solid var(--border-dim); border-top: 2px solid var(--panel-border);
    border-radius: 10px; padding: 20px; max-width: 920px; width: 100%;
    max-height: 92vh; overflow-y: auto;
    box-shadow: 0 16px 48px rgba(0,0,0,0.9);
  }
  .modal-title {
    margin: 0 0 14px; font-size: 22px; font-weight: 800; color: var(--gold);
    letter-spacing: 1px; display: flex; justify-content: space-between; align-items: center;
  }
  .btn-primary {
    background: linear-gradient(180deg, #1e88e5, #125296);
    border: 1px solid #60a5fa; color: #fff; font-weight: 700;
    padding: 10px 24px; border-radius: 6px; cursor: pointer; font-size: 15px;
    transition: filter 0.15s;
  }
  .btn-primary:hover { filter: brightness(1.15); }
  .btn-gold {
    background: linear-gradient(180deg, #d99b26, #966510);
    border: 1px solid #fde68a; color: #fff; font-weight: 700;
    padding: 10px 26px; border-radius: 6px; cursor: pointer; font-size: 15px;
  }
  .btn-gold:hover { filter: brightness(1.15); }
  .btn-danger {
    background: linear-gradient(180deg, #dc2626, #991b1b);
    border: 1px solid #fca5a5; color: #fff; font-weight: 700;
    padding: 8px 18px; border-radius: 6px; cursor: pointer;
  }

  /* Hero Select */
  #hero-select-screen { display: flex; }
  .hero-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px;
  }
  .hero-option {
    background: rgba(15, 25, 42, 0.85); border: 2px solid #2b384e;
    border-radius: 8px; padding: 14px; cursor: pointer; transition: all 0.18s;
  }
  .hero-option:hover { border-color: #8b7339; transform: translateY(-2px); }
  .hero-option.selected {
    border-color: var(--gold); background: rgba(26, 42, 70, 0.95);
    box-shadow: 0 0 20px rgba(240, 192, 64, 0.28);
  }
  .hero-opt-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
  .hero-opt-icon {
    width: 46px; height: 46px; border-radius: 50%; display: flex;
    align-items: center; justify-content: center; font-size: 22px;
    border: 2px solid var(--panel-border); background: #0c1726;
  }
  .hero-role-tag {
    font-size: 11px; padding: 2px 7px; border-radius: 4px;
    background: #1d2f4d; color: #93c5fd; font-weight: 700;
  }
  .hero-skill-list { font-size: 12px; color: var(--text-sub); line-height: 1.5; margin-top: 6px; }
  .hero-skill-list b { color: var(--text-main); }

  .diff-row {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 12px; padding-top: 12px; border-top: 1px solid #233046;
  }
  .diff-pills { display: flex; gap: 8px; }
  .diff-pill {
    padding: 7px 14px; border-radius: 5px; border: 1px solid #38465e;
    background: #0d1626; color: var(--text-sub); cursor: pointer; font-weight: 600;
  }
  .diff-pill.active { border-color: var(--gold); color: var(--gold); background: #1d2738; }

  /* Shop */
  .shop-tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
  .shop-tab {
    padding: 6px 14px; border-radius: 5px; border: 1px solid #35435a;
    background: #0d1624; color: var(--text-sub); cursor: pointer; font-size: 13px; font-weight: 600;
  }
  .shop-tab.active { border-color: var(--gold); color: var(--gold); background: #1a2840; }
  .shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
  .shop-item {
    background: #0d1728; border: 1px solid #2b384e; border-radius: 6px;
    padding: 10px; display: flex; flex-direction: column; justify-content: space-between; gap: 6px;
  }
  .shop-item-head { display: flex; align-items: center; gap: 8px; }
  .shop-item-icon {
    width: 34px; height: 34px; border-radius: 5px; background: #182740;
    border: 1px solid #574520; display: flex; align-items: center; justify-content: center; font-size: 18px;
  }
  .shop-buy-btn {
    padding: 5px 10px; border-radius: 4px; border: 1px solid var(--gold);
    background: #2b2310; color: var(--gold); font-weight: 700; cursor: pointer; font-size: 12px;
  }
  .shop-buy-btn:disabled { opacity: 0.4; cursor: not-allowed; border-color: #444; color: #888; background: #121720; }
  .shop-owned-row {
    margin-top: 12px; padding-top: 10px; border-top: 1px solid #25334a;
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  }
  .owned-chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px;
    background: #142238; border: 1px solid #594722; border-radius: 4px; font-size: 12px;
  }
  .owned-chip button {
    background: #5c1e24; border: none; color: #fca5a5; border-radius: 3px; cursor: pointer; font-size: 11px; padding: 1px 5px;
  }

  /* Scoreboard Table */
  .sb-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 12px; }
  .sb-table th { text-align: left; padding: 6px 8px; border-bottom: 1px solid #2e3c54; color: var(--text-sub); }
  .sb-table td { padding: 7px 8px; border-bottom: 1px solid #182336; }

  /* Mobile / Narrow Responsive */
  #mobile-hint { display: none; }
  @media (max-width: 860px) {
    .hero-grid { grid-template-columns: 1fr; }
    #minimap-wrap { width: 124px; height: 124px; top: 44px; bottom: auto; right: 8px; }
    #bottom-hud { transform: translateX(-50%) scale(0.78); bottom: 4px; }
    #top-bar { padding: 4px 10px; font-size: 11px; gap: 8px; }
    #hero-card { display: none; }
  }
  @media (max-width: 540px) {
    #bottom-hud { transform: translateX(-50%) scale(0.65); }
    #minimap-wrap { width: 104px; height: 104px; }
  }

  #cdn-error {
    position: fixed; inset: 0; background: #09101a; color: #f87171;
    display: none; flex-direction: column; align-items: center; justify-content: center;
    padding: 24px; text-align: center; z-index: 999;
  }
</style>
</head>
<body>

<div id="cdn-error">
  <h2>资源加载失败</h2>
  <p>无法从 CDN 加载 Three.js (0.160.0) 核心库,请检查网络连接后刷新重试。</p>
</div>

<div id="game-container">
  <canvas id="webgl-canvas"></canvas>
  <canvas id="overlay-c.........完整代码请登录后点击上方下载按钮下载查看

网友评论0