three+webrtc实现双人语音三维拉弓射箭游戏代码
代码语言:html
所属分类:游戏
代码描述:three+webrtc实现双人语音三维拉弓射箭游戏代码
代码标签: three webrtc 双人 语音 三维 拉弓 射箭 游戏 代码
下面为部分代码预览,完整代码请点击下载或在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>WebRTC 双人城堡射箭对战</title>
<style>
body { margin: 0; overflow: hidden; font-family: 'Microsoft YaHei', sans-serif; background: #87b7ff; color: white; user-select: none; }
#game-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
/* UI 层 */
#ui-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
.hud-top {
display: flex; justify-content: space-between; padding: 20px;
text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}
.hp-bar-container { width: 250px; height: 22px; background: rgba(0,0,0,0.5); border: 2px solid rgba(255,255,255,0.3); border-radius: 8px; overflow: hidden; margin-top: 5px; box-shadow: 0 4px 6px rgba(0,0,0,0.3); }
.hp-bar { height: 100%; width: 100%; background: linear-gradient(90deg, #4caf50, #8bc34a); transition: width 0.2s, background 0.2s; }
.hp-bar.enemy { background: linear-gradient(90deg, #f44336, #ff9800); }
#crosshair {
position: absolute; top: 50%; left: 50%; width: 20px; height: 20px;
transform: translate(-50%, -50%);
}
#crosshair::before, #crosshair::after {
content: ""; position: absolute; background: rgba(255,255,255,0.95); box-shadow: 0 0 4px rgba(0,0,0,0.5);
}
#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%); }
/* 蓄力条 */
#powerWrap {
position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%);
width: 300px; height: 16px; border-radius: 8px; overflow: hidden;
background: rgba(0,0,0,0.4); border: 1px solid rgba(255,255,255,0.5);
}
#powerBar { width: 0%; height: 100%; background: linear-gradient(90deg, #79ffae, #ffd66b, #ff7b7b); transition: width 0.05s linear; }
/* 菜单/弹窗 */
.menu-overlay {
position: absolute; inset: 0; background: radial-gradient(circle at center, rgba(0,0,0,0.7), rgba(0,0,0,0.95));
display: flex; flex-direction: column; justify-content: center; align-items: center; pointer-events: auto; z-index: 100;
}
.card {
background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
padding: 30px 40px; border-radius: 16px; text-align: center; backdrop-filter: blur(10px);
box-shadow: 0 10px 30px rgba(0,0,0,0.5); max-width: 400px;
}
h1 { margin: 0 0 15px; font-size: 28px; color: #fff; text-shadow: 0 2px 5px rgba(0,0,0,0.5); }
p { color: #ccc; line-height: 1.6; margin-bottom: 20px; }
.btn {
padding: 12px 30px; font-size: 16px; font-weight: bold; margin: 10px 5px; cursor: pointer;
background: #fff; color: #222; border: none; border-radius: 8px;
transition: all 0.2s; pointer-events: auto; box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
.btn:hover { background: #e0e0e0; transform: translateY(-2px); }
.btn:active { transform: scale(0.95); }
.btn-red { background: #ff4444; color: white; }
.btn-red:hover { background: #ff2222; }
#qrcode { margin: 20px auto; background: white; padding: 10px; border-radius: 8px; display: inline-block; }
#shareLink { width: 100%; padding: 10px; box-sizing: border-box; border-radius: 4px; border: none; background: rgba(0,0,0,0.3); color: white; text-align: center; margin-bottom: 10px; }
.status-tag {
position: fixed; bottom: 20px; left: 20px; background: rgba(0,0,0,0.6);
padding: 8px 15px; border-radius: 20px; font-size: 14px; backdrop-filter: blur(4px);
}
.mic-icon { cursor: pointer; pointer-events: auto; font-size: 18px; margin-left: 10px; }
#damageFlash { position: absolute; inset: 0; background: rgba(255,0,0,0.25); opacity: 0; transition: op.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0