three实现坦克大战三维游戏代码
代码语言:html
所属分类:游戏
代码描述:three实现坦克大战三维游戏代码,wasd移动坦克,鼠标移动瞄准,点击发射炮弹。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3D 坦克大战</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { overflow: hidden; background: #000; font-family: 'Arial', sans-serif; }
canvas { display: block; }
#loading {
position: fixed;
top: 0; left: 0;
width: 100%; height: 100%;
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 1000;
transition: opacity 0.5s;
}
#loading h1 {
color: #e94560;
font-size: 48px;
text-shadow: 0 0 20px rgba(233, 69, 96, 0.5);
margin-bottom: 30px;
}
.loader {
width: 200px;
height: 4px;
background: #333;
border-radius: 2px;
overflow: hidden;
}
.loader-bar {
height: 100%;
background: linear-gradient(90deg, #e94560, #ff6b6b);
animation: loading 1.5s ease-in-out infinite;
}
@keyframes loading {
0% { width: 0; }
50% { width: 100%; }
100% { width: 0; }
}
#ui {
position: absolute;
top: 20px;
left: 20px;
color: white;
user-select: none;
}
#score {
font-size: 28px;
font-weight: bold;
text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
margin-bottom: 10px;
}
#health-container {
background: rgba(0,0,0,0.5);
padding: 10px 15px;
border-radius: 10px;
backdrop-filter: blur(5px);
}
#health-label {
font-size: 14px;
margin-bottom: 5px;
color: #aaa;
}
#health-bar {
width: 220px;
height: 20px;
background: linear-gradient(180deg, #2a2a2a, #1a1a1a);
border-radius: 10px;
overflow: hidden;
box-shadow: inset 0 2px 5px rgba(0,0,0,0.5);
}
#health-fill {
height: 100%;
background: linear-gradient(180deg, #4ade80, #22c55e);
width: 100%;
transition: width 0.3s, background 0.3s;
border-radius: 10px;
box-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
}
#health-fill.low {
background: linear-gradient(180deg, #f87171, #ef4444);
box-shadow: 0 0 10px rgba(248, 113, 113, 0.5);
}
#ammo-display {
margin-top: 10px;
font-size: 16px;
}
#crosshair {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
pointer-events: none;
z-index: 100;
}
#crosshair svg {
width: 60px;
height: 60px;
filter: drop-shadow(0 0 3px rgba(255,255,255,0.5));
}
#minimap {
position: absolute;
bottom: 20px;
right: 20px;
width: 180px;
height: 180px;
background: rgba(0, 20, 0, 0.7);
border: 3px solid #444;
border-radius: 10px;
box-shadow: 0 0 20px rgba(0,0,0,0.5);
}
#instructions {
position: absolute;
bottom: 20px;
left: 20px;
color: white;
font-size: 13px;
background: rgba(0,0,0,0.6);
padding: 15px;
border-radius: 10px;
backdrop-filter: blur(5px);
line-height: 1.6;
}
#instructions span {
color: #4ade80;
font-weight: bold;
}
#kill-feed {
position: absolute;
top: 20px;
right: 20px;
width: 250px;
}
.kill-message {
background: rgba(0,0,0,0.7);
color: #ff6b6b;
padding: 8px 15px;
margin-bottom: 5px;
border-radius: 5px;
font-size: 14px;
animation: slideIn 0.3s ease-out;
border-left: 3px solid #e94560;
}
@keyframes slideIn {
from { transform: translateX(100px); opacity: 0; }
to { transform: translateX(0); opacity: 1; }
}
#damage-overlay {
position: fixed;
top: 0; left: 0;
width: 100%; height: 100%;
pointer-events: none;
z-index: 50;
opacity: 0;
background: radial-gradient(ellipse at center, transparent 0%, rgba(255,0,0,0.3) 100%);
transition: opacity 0.1s;
}
#wave-indicator {
position: absolute;
top: 80px;
left: 50%;
transform: translateX(-50%);
color: #ffd700;
font-size: 24px;
font-weight: bold;
.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0