three实现小船河流行驶躲避桥梁游戏代码

代码语言:html

所属分类:其他

代码描述:3d小船行驶躲避桥梁游戏

代码标签: 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>
        :root {
            --bg: #1a1a2e;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            overflow: hidden;
            background: var(--bg);
            font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
            touch-action: manipulation;
            -webkit-touch-callout: none;
            -webkit-user-select: none;
            user-select: none;
            height: 100vh;
            width: 100vw;
            position: fixed;
        }

        #gameCanvas {
            display: block;
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }

        /* HUD 顶部信息栏 */
        #hud {
            position: absolute;
            top: 20px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            gap: 24px;
            align-items: center;
            z-index: 10;
            pointer-events: none;
        }

        .hud-item {
            background: rgba(0, 0, 0, 0.55);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid rgba(255, 255, 255, 0.18);
            border-radius: 14px;
            padding: 10px 18px;
            color: #fff;
            text-align: center;
            min-width: 70px;
        }
        .hud-label {
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: 2px;
            opacity: 0.7;
            margin-bottom: 2px;
        }
        .hud-value {
            font-size: 26px;
            font-weight: 700;
            line-height: 1;
        }
        .hud-value.score {
            color: #FFD700;
        }
        .hud-value.speed {
            color: #4FC3F7;
        }

        /* 底部提示 */
        #hint {
            position: absolute;
            bottom: 100px;
            left: 50%;
            transform: translateX(-50%);
            color: #fff;
            font-size: 15px;
            background: rgba(0, 0, 0, 0.5);
            padding: 8px 20px;
            border-radius: 20px;
            z-index: 10;
            pointer-events: none;
            transition: opacity 0.4s;
            letter-spacing: 1px;
        }

        /* 游戏结束画面 */
        #gameOverPanel {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%) scale(0);
            background: rgba(20, 20, 35, 0.92);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border: 2px solid rgba(255, 255, 255, 0.2);
            border-radius: 24px;
            padding: 40px 50px;
            text-align: center;
            color: #fff;
            z-index: 20;
            transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            pointer-events: none;
        }
        #gameOverPanel.show {
            transform: translate(-50%, -50%) scale(1);
            pointer-events: all;
        }
        #gameOverPanel h2 {
            font-size: 36px;
            margin-bottom: 8px;
            letter-spacing: 2px;
        }
        #gameOverPanel .final-score {
            font-size: 60px;
            font-weight: 900;
            color: #FFD700;
            margin: 12px 0;
        }
        #gameOverPanel .best-score {
            font-size: 16px;
            opacity: 0.7;
            margin-bottom: 24px;
        }
        #gameOverPanel button {
            background: linear-gradient(135deg, #FF6B6B, #ee5a24);
            color: #fff;
            border: none;
            padding: 14px 40px;
            font-size: 18px;
            border-radius: 30px;
            cursor: pointer;
            letter-spacing: 2px;
            font-weight: 700;
            transition: transform 0.15s, box-shadow 0.15s;
            box-shadow: 0 8px 30px rgba(238, 90, 36, 0.4);
        }
        #gameOverPanel button:hover {
            transform: scale(1.05);
            box-shadow: 0 12px 36px rgba(238, 90, 36, 0.55);
        }
        #gameOverPanel button:active {
            transform: scale(0.95);
        }

        /* 移动端虚拟按钮 */
        #mobileControls {
            display: none;
            position: absolute;
            bottom: 20px;
            left: 0;
            right: 0;
            z-index: 15;
            padding: 0 16px;
            pointer-events: none;
        }
        #mobileControls .btn-row {
            display: flex;
            justi.........完整代码请登录后点击上方下载按钮下载查看

网友评论0