three实现三维古墓探险游戏代码

代码语言:html

所属分类:游戏

代码描述:three实现三维古墓探险游戏代码,WASD / 方向键移动,Shift 奔跑, 视野会随火把燃料减少而变暗,靠近墙上火把可补充,收集宝藏:金色宝箱+100分,宝石会闪烁发光, 寻找钥匙:打开

代码标签: three 三维 古墓 探险 游戏 代码

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

<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>古墓探险 - Tomb Explorer 3D</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { overflow: hidden; background: #000; font-family: 'Georgia', serif; }
canvas { display: block; }

#blocker {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#title {
    font-size: 64px;
    color: #D4A847;
    text-shadow: 0 0 20px rgba(212,168,71,0.5), 0 4px 8px rgba(0,0,0,0.8);
    margin-bottom: 10px;
    letter-spacing: 8px;
    text-align: center;
}

#subtitle {
    font-size: 18px;
    color: #A08040;
    margin-bottom: 40px;
    letter-spacing: 4px;
}

#startBtn {
    padding: 15px 50px;
    font-size: 22px;
    background: linear-gradient(180deg, #D4A847, #8B6914);
    color: #1a0a00;
    border: 2px solid #D4A847;
    cursor: pointer;
    letter-spacing: 4px;
    font-family: 'Georgia', serif;
    transition: all 0.3s;
}
#startBtn:hover {
    background: linear-gradient(180deg, #E8C060, #A07820);
    box-shadow: 0 0 30px rgba(212,168,71,0.5);
}

#hud {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 10;
    display: none;
}

/* 受伤屏幕泛红图层 */
#damageOverlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle, rgba(255,0,0,0) 40%, rgba(255,0,0,0.6) 100%);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    z-index: 5;
}

#healthBar {
    position: absolute;
    top: 20px; left: 20px;
    width: 200px; height: 12px;
    background: rgba(0,0,0,0.6);
    border: 1px solid #D4A847;
    border-radius: 6px;
    overflow: hidden;
}
#healthFill {
    width: 100%; height: 100%;
    background: linear-gradient(90deg, #ff3030, #ff6030, #40ff40);
    border-radius: 6px;
    transition: width 0.3s;
}

#healthLabel {
    position: absolute;
    top: 6px; left: 24px;
    color: #D4A847;
    font-size: 11px;
}

#torchBar {
    position: absolute;
    top: 44px; left: 20px;
    width: 200px; height: 12px;
    background: rgba(0,0,0,0.6);
    border: 1px solid #D4A847;
    border-radius: 6px;
    overflow: hidden;
}
#torchFill {
    width: 100%; height: 100%;
    background: linear-gradient(90deg, #804000, #ff8020, #ffcc00);
    border-radius: 6px;
    transition: width 0.3s;
}

#torchLabel {
    position: absolute;
    top: 30px; left: 24px;
    color: #D4A847;
    font-size: 11px;
}

#score {
    position: absolute;
    top: 20px; right: 20px;
    color: #D4A847;
    font-size: 20px;
    text-shadow: 0 0 10px rgba(212,168,71,0.5);
}

#inventory {
    position: absolute;
    bottom: 20px; left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
}
.inv-slot {
    width: 50px; height: 50px;
    background: rgba(0,0,0,0.6);
    border: 1px solid #D4A847;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

#message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #D4A847;
    font-size: 24px;
    text-shadow: 0 0 20px rgba(212,168,71,0.8);
    opacity: 0;
    transition: opacity 0.5s;
    text-align: center;
    white-space: pre-line;
}

#crosshair {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 20px; height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
}

#minimap {
    position: absolute;
    bottom: 20px; right: 20px;
    width: 160px; height: 160px;
    background: rgba(0,0,0,0.7);
    border: 1px solid #D4A847;
    border-radius: 4px;
}

#controls {
    position: absolute;
    bottom: 80px;
    left: 20px;
    color: #888;
    font-size: 12px;
    line-height: 1.8;
}
</style>
</head>
<body>

<div id="blocker">
    <div id="title">古墓探险</div>
    <div id="subtitle">TOMB EXPLORER</div>
    <button id="startBtn" onclick="startGame()">开始探险</button>
</div>

<div id="hud">
    <div id="damageOverlay"></div>
    <div id="healthLabel">生命值</div>
    <div id="healthBar"><div id="healthFill"></div></div>
    <div id="torchLabel">火把</div>
    <div id="torchBar"><div id="torchFill.........完整代码请登录后点击上方下载按钮下载查看

网友评论0