three实现的经典三维塔防游戏代码
代码语言:html
所属分类:游戏
代码描述:three实现的经典三维塔防游戏代码, 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>3D塔防游戏</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
overflow: hidden;
background: #000;
font-family: 'Segoe UI', Arial, sans-serif;
}
#gameCanvas {
display: block;
}
#ui {
position: fixed;
top: 0;
left: 0;
right: 0;
padding: 15px;
display: flex;
justify-content: space-between;
align-items: center;
background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, transparent 100%);
pointer-events: none;
}
.stats {
display: flex;
gap: 30px;
}
.stat {
display: flex;
align-items: center;
gap: 8px;
color: #fff;
font-size: 18px;
text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}
.stat-icon {
font-size: 24px;
}
.stat-value {
font-weight: bold;
min-width: 50px;
}
#towerPanel {
position: fixed;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
display: flex;
gap: 15px;
padding: 15px 25px;
background: rgba(0,0,0,0.85);
border-radius: 20px;
border: 2px solid rgba(255,255,255,0.1);
backdrop-filter: blur(10px);
}
.tower-btn {
width: 80px;
height: 100px;
border: 2px solid rgba(255,255,255,0.2);
border-radius: 15px;
background: linear-gradient(145deg, rgba(255,255,255,0.1), rgba(0,0,0,0.3));
cursor: pointer;
transition: all 0.3s ease;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 5px;
pointer-events: auto;
}
.tower-btn:hover {
transform: translateY(-5px);
border-color: rgba(255,255,255,0.5);
box-shadow: 0 10px 30px rgba(0,150,255,0.3);
}
.tower-btn.selected {
border-color: #00ff88;
box-shadow: 0 0 30px rgba(0,255,136,0.5);
}
.tower-btn.disabled {
opacity: 0.4;
cursor: not-allowed;
}
.tower-icon {
font-size: 32px;
}
.tower-name {
color: #fff;
font-size: 11px;
font-weight: bold;
}
.tower-cost {
color: #ffd700;
font-size: 12px;
}
#waveInfo {
position: fixed;
top: 80px;
left: 50%;
transform: translateX(-50%);
color: #fff;
font-size: 24px;
text-shadow: 0 0 20px rgba(255,100,0,0.8);
opacity: 0;
transition: opacity 0.5s;
pointer-events: none;
}
#startBtn {
position: fixed;
bottom: 150px;
left: 50%;
transform: translateX(-50%);
padding: 15px 50px;
font-size: 20px;
font-weight: bold;
color: #fff;
background: linear-gradient(145deg, #ff6b00, #ff3300);
border: none;
border-radius: 30px;
cursor: pointer;
box-shadow: 0 5px 30px rgba(255,100,0,0.5);
transition: all 0.3s;
}
#startBtn:hover {
transform: translateX(-50%) scale(1.1);
box-shadow: 0 10px 40px rgba(255,100,0,0.7);
}
#gameOver {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.9);
display: none;
justify-content: center;
align-items: center;
flex-direction: column;
gap: 30px;
}
#gameOver h1 {
color: #ff3333;
font-size: 60px;
text-shadow: 0 0 50px rgba(255,0,0,0.8);
}
#gameOver p {
color: #fff;
font-size: 24px;
}
#restartBtn {
padding: 15px 50px;
font-size: 20px;
font-weight: bold;
color: #fff;
background: linear-gradient(145deg, #00aa55, #008844);
border: none;
border-radius: 30px;
cursor: pointer;
}
#tooltip {
position: fixed;
padding: 10px 15px;
background: rgba(0,0,0,0.9);
color: #fff;
border-radius: 10.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0