three实现5对5人机对战三维踢足球游戏代码
代码语言:html
所属分类:游戏
代码描述:three实现5对5人机对战三维踢足球游戏代码 WASD/方向键: 移动 | SHIFT: 加速 | 空格(蓄力): 射门 | E: 传球 | Q: 切换球员 | C: 切换视角 | R: 铲球,按 Q 切换球员
代码标签: three实现5对5人机对战三维踢足球游戏代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>5v5 足球对战</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { overflow: hidden; background: #000; font-family: 'Arial', sans-serif; }
canvas { display: block; }
#ui {
position: absolute; top: 0; left: 0; width: 100%;
pointer-events: none; z-index: 10;
}
#scoreboard {
display: flex; justify-content: center; align-items: center;
gap: 30px; padding: 10px;
background: rgba(0,0,0,0.7); color: white;
font-size: 24px; font-weight: bold;
}
#scoreboard .team-blue { color: #4488ff; }
#scoreboard .team-red { color: #ff4444; }
#scoreboard .score { font-size: 36px; }
#timer { color: #ffcc00; }
#controls-info {
position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
background: rgba(0,0,0,0.7); color: white; padding: 10px 20px;
border-radius: 10px; font-size: 13px; text-align: center;
pointer-events: none;
}
#minimap {
position: absolute; bottom: 60px; right: 10px;
width: 200px; height: 130px;
background: rgba(0,80,0,0.8); border: 2px solid #fff;
border-radius: 5px;
}
#goalMessage {
position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
font-size: 72px; font-weight: bold; color: #ffcc00;
text-shadow: 0 0 20px rgba(255,200,0,0.8), 0 0 40px rgba(255,200,0,0.5);
display: none; pointer-events: none;
animation: goalPulse 0.5s ease-in-out infinite alternate;
}
@keyframes goalPulse {
from { transform: translate(-50%,-50%) scale(1); }
to { transform: translate(-50%,-50%) scale(1.2); }
}
#startScreen {
position: absolute; top: 0; left: 0; 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;
color: white;
}
#startScreen h1 {
font-size: 60px; color: #4CAF50; margin-bottom: 20px;
text-shadow: 0 0 20px rgba(76,175,80,0.5);
}
#startScreen .subtitle { font-size: 24px; color: #ccc; margin-bottom: 40px; }
#startBtn {
padding: 15px 60px; font-size: 24px; background: #4CAF50;
color: white; border: none; border-radius: 10px; cursor: pointer;
pointer-events: all; transition: all 0.3s;
}
#startBtn:hover { background: #66BB6A; transform: scale(1.05); }
#powerBar {
position: absolute; bottom: 100px; left: 50%; transform: translateX(-50%);
width: 200px; height: 20px; background: rgba(0,0,0,0.5);
border: 2px solid white; border-radius: 10px; overflow: hidden;
display: none;
}
#powerFill {
height: 100%; width: 0%;
background: linear-gradient(90deg, #00ff00, #ffff00, #ff0000);
transition: width 0.05s;
}
#switchHint {
position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
background: rgba(0,0,0,0.6); color: #ffcc00; padding: 5px 15px;
border-radius: 5px; font-size: 14px; display: none;
pointer-events: none;
}
#mobileControls {
display: none;
position: absolute;
bottom: 20px;
left: 0;
width: 100%;
pointer-events: none;
z-index: 20;
}
.joystick-zone {
position: absolute;
bottom: 20px;
left: 20px;
width: 120px;
height: 120px;
background: rgba(255,255,255,0.15);
border-radius: 50%;
border: 2px solid rgba(255,255,255,0.3);
pointer-events: all;
}
.joystick-knob {
position: absolute;
width: 50px; height: 50px;
background: rgba(255,255,255,0.5);
border-radius: 50%;
top: 50%; left: 50%;
transform: translate(-50%,-50%);
}
.action-buttons {
position: absolute;
bottom: 20px;
right: 20px;
display: flex;
gap: 10px;
pointer-events: all;
}
.action-btn {
width: 60px; height: 60px;
border-radius: 50%;
border: 2px solid rgba(255,255,255,0.5);
color: white;
font-size: 12px;
font-weight: bold;
display: flex;
align-items: center;
justify-content: center;
pointer-events: all;
-webkit-user-select: none;
user-select: none;
}
.btn-shoot { background: rgba(255,50,50,0.6); }
.btn-pass { background: rgba(50,100,255,0.6); }
.btn-sprint { background: rgba(50,255,50,0.6); }
.btn-switch { background: rgba(255,200,50,0.6); }
</style>
</head>
<body>
<div id="ui">
<div id="scoreboard">
<span class="team-blue">⚽ 蓝队 (你)</span>
<span class="score"><span id="blueScore">0</span> - <span id="redScore">0</span></span>
<span class="team-red">红队 (AI) ⚽</span>
<span id="timer">05:00</span>
</div>
</div>
<div id="goalMessage">⚽ GOAL! ⚽</div>
<div id="switchHint">按 Q 切换球员</div>
<div id="powerBar"><div id="powerFill"></div></div>
<canvas id="minimap"></canvas>
<div id="controls-info">
WASD/方向键: 移动 | SHIFT: 加速 | 空格(蓄力): 射门 | E: 传球 | Q: 切换球员 | C: 切换视角 | R: 铲球
</div>
<div id="mobileControls">
<div class="joystick-zone" id="joystickZone">
<div class="joystick-knob" id="joystickKnob"></div>
</div>
<div cla.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0