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, user-scalable=no" />
    <title>3D 人机对战投篮游戏</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            user-select: none;
            -webkit-tap-highlight-color: transparent;
        }

        html, body {
            width: 100%;
            height: 100%;
            overflow: hidden;
            background: #05070d;
            font-family: "Microsoft YaHei", Arial, sans-serif;
            color: white;
        }

        #app {
            position: relative;
            width: 100vw;
            height: 100vh;
        }

        canvas {
            display: block;
            width: 100%;
            height: 100%;
        }

        #hud {
            position: absolute;
            top: 14px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            align-items: center;
            gap: 18px;
            padding: 10px 22px;
            background: rgba(0, 0, 0, 0.42);
            border: 1px solid rgba(255, 255, 255, 0.12);
            border-radius: 16px;
            backdrop-filter: blur(8px);
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
            z-index: 10;
        }

        .scoreBox {
            text-align: center;
            min-width: 70px;
        }

        .scoreName {
            font-size: 13px;
            opacity: 0.82;
            margin-bottom: 4px;
        }

        .scoreValue {
            font-size: 34px;
            font-weight: 900;
            line-height: 1;
        }

        #scoreP {
            color: #4ade80;
        }

        #scoreA {
            color: #f87171;
        }

        #roundInfo {
            text-align: center;
            min-width: 120px;
        }

        #roundText {
            font-size: 16px;
            font-weight: bold;
            color: #facc15;
        }

        #modeText {
            margin-top: 4px;
            font-size: 13px;
            color: #e5e7eb;
        }

        #message {
            position: absolute;
            top: 96px;
            left: 50%;
            transform: translateX(-50%);
            padding: 10px 24px;
            background: rgba(0, 0, 0, 0.45);
            border-radius: 999px;
            font-size: 20px;
            font-weight: bold;
            letter-spacing: 1px;
            opacity: 0;
            transition: opacity 0.25s ease;
            z-index: 10;
            pointer-events: none;
            text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
        }

        #powerWrap {
            position: absolute;
            bottom: 34px;
            left: 50%;
            transform: translateX(-50%);
            width: min(460px, 82vw);
            z-index: 10;
            display: none;
        }

        #powerLabel {
            text-align: center;
            margin-bottom: 8px;
            font-size: 14px;
            color: #fde68a;
            text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
        }

        #powerBar {
            position: relative;
            width: 100%;
            height: 22px;
            background: rgba(255, 255, 255, 0.14);
            border-radius: 999px;
            overflow: hidden;
            border: 1px solid rgba(255, 255, 255, 0.16);
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
        }

        #powerFill {
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 0%;
            background: linear-gradient(90deg, #f97316, #fb923c);
            transition: background 0.08s linear;
        }

        #targetZone {
            position: absolute;
            top: 0;
            bottom: 0;
            background: rgba(74, 222, 128, 0.34);
            border-left: 2px solid rgba(255, 255, 255, 0.55);
            border-right: 2px solid rgba(255, 255, 255, 0.55);
        }

        #instructions {
            position: absolute;
            bottom: 90px;
            left: 50%;
            transform: translateX(-50%);
            font-size: 14px;
            color: rgba(255, 255, 255, 0.82);
            background: rgba(0, 0, 0, 0.28);
            padding: 8px 16px;
            border-radius: 999px;
            z-index: 10;
            pointer-events: none;
            white-space: nowrap;
        }

        #overlay {
            position: absolute;
            inset: 0;
            background: radial-gradient(circle at center, rgba(15, 23, 42, 0.72), rgba(2, 6, 23, 0.9));
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            text-align: center.........完整代码请登录后点击上方下载按钮下载查看

网友评论0