three实现三维拉弓射箭杀敌攻城游戏代码

代码语言:html

所属分类:游戏

代码描述: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>Three.js 第一人称城堡射箭游戏</title>
  <style>
    html, body {
      margin: 0;
      width: 100%;
      height: 100%;
      overflow: hidden;
      background: #87b7ff;
      font-family: Arial, "Microsoft YaHei", sans-serif;
      user-select: none;
    }
    #game {
      position: relative;
      width: 100%;
      height: 100%;
    }
    canvas { display: block; }

    #ui {
      position: absolute;
      inset: 0;
      pointer-events: none;
    }

    #crosshair {
      position: absolute;
      left: 50%;
      top: 50%;
      width: 20px;
      height: 20px;
      margin-left: -10px;
      margin-top: -10px;
    }
    #crosshair::before,
    #crosshair::after {
      content: "";
      position: absolute;
      background: rgba(255,255,255,0.95);
      box-shadow: 0 0 6px rgba(0,0,0,0.35);
    }
    #crosshair::before {
      left: 50%;
      top: 0;
      width: 2px;
      height: 20px;
      transform: translateX(-50%);
    }
    #crosshair::after {
      left: 0;
      top: 50%;
      width: 20px;
      height: 2px;
      transform: translateY(-50%);
    }

    #hud {
      position: absolute;
      left: 16px;
      top: 16px;
      color: #fff;
      background: rgba(0,0,0,0.2);
      padding: 12px 16px;
      border-radius: 12px;
      line-height: 1.8;
      font-size: 16px;
      text-shadow: 0 2px 6px rgba(0,0,0,0.35);
      backdrop-filter: blur(4px);
    }

    #powerWrap {
      position: absolute;
      left: 50%;
      bottom: 26px;
      transform: translateX(-50%);
      width: 320px;
      height: 18px;
      border-radius: 999px;
      overflow: hidden;
      background: rgba(255,255,255,0.2);
      border: 1px solid rgba(255,255,255,0.45);
      box-shadow: 0 4px 12px rgba(0,0,0,0.22);
    }
    #powerBar {
      width: 0%;
      height: 100%;
      background: linear-gradient(90deg, #79ffae 0%, #ffd66b 55%, #ff7b7b 100%);
      transition: width 0.03s linear;
    }

    #message {
      position: absolute;
      left: 50%;
      top: 90px;
      transform: translateX(-50%);
      color: #fff;
      font-size: 28px;
      font-weight: bold;
      text-shadow: 0 4px 10px rgba(0,0,0,0.35);
      opacity: 0;
      transition: opacity .2s ease;
    }

    #panel {
      position: absolute;
      inset: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      pointer-events: auto;
      background: radial-gradient(circle at center, rgba(255,255,255,0.08), rgba(0,0,0,0.38));
    }

    #card {
      color: #fff;
      background: rgba(255,255,255,0.12);
      border: 1px solid rgba(255,255,255,0.22);
      border-radius: 18px;
      padding: 28px 34px;
      max-width: 520px;
      text-align: center;
      box-shadow: 0 12px 32px rgba(0,0,0,0.25);
      backdrop-filter: blur(8px);
    }

    #card h1 {
      margin: 0 0 12px;
      font-size: 30px;
    }
    #card p {
      margin: 8px 0;
      line-height: 1.8;
      font-size: 15px;
    }
    #startBtn {
      margin-top: 14px;
      border: none;
      border-radius: 12px;
      padding: 12px 24px;
      cursor: pointer;
      font-size: 16px;
      color: #23415b;
      background: #fff;
      box-shadow: 0 6px 16px rgba(0,0,0,0.2);
      transition: transform 0.1s;
    }
    #startBtn:active {
      transform: scale(0.95);
    }

    #damageFlash {
      position: absolute;
      inset: 0;
      background: rgba(255,0,0,0.18);
      opacity: 0;
      .........完整代码请登录后点击上方下载按钮下载查看

网友评论0