three实现带音效跳一跳游戏代码
代码语言:html
所属分类:游戏
代码描述:three实现带音效跳一跳游戏代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>3D 跳一跳 - 终极版</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
overflow: hidden;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
touch-action: none;
-webkit-user-select: none;
user-select: none;
background: #1a1a2e;
}
canvas {
display: block;
}
#ui {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 100;
}
#topBar {
position: absolute;
top: 0;
left: 0;
right: 0;
padding: 20px;
display: flex;
justify-content: space-between;
align-items: flex-start;
}
#score {
font-size: 64px;
font-weight: 800;
color: #fff;
text-shadow: 0 4px 20px rgba(0,0,0,0.3);
transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
line-height: 1;
}
#score.pop {
transform: scale(1.2);
}
#stats {
text-align: right;
color: rgba(255,255,255,0.7);
font-size: 14px;
}
#stats div {
margin-bottom: 5px;
}
#soundBtn {
position: absolute;
top: 20px;
right: 20px;
width: 44px;
height: 44px;
border-radius: 50%;
background: rgba(255,255,255,0.15);
border: none;
cursor: pointer;
pointer-events: auto;
display: flex;
align-items: center;
justify-content: center;
backdrop-filter: blur(10px);
transition: all 0.3s;
}
#soundBtn:hover {
background: rgba(255,255,255,0.25);
transform: scale(1.1);
}
#soundBtn svg {
width: 24px;
height: 24px;
fill: white;
}
#powerContainer {
position: absolute;
bottom: 80px;
left: 50%;
transform: translateX(-50%);
width: 200px;
height: 8px;
background: rgba(255,255,255,0.15);
border-radius: 4px;
overflow: hidden;
opacity: 0;
transition: opacity 0.2s ease;
backdrop-filter: blur(10px);
}
#powerContainer.show {
opacity: 1;
}
#powerFill {
height: 100%;
width: 0%;
background: linear-gradient(90deg, #00f5a0, #00d9f5, #f5a0ff);
border-radius: 4px;
box-shadow: 0 0 20px rgba(0,245,160,0.5);
}
#combo {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) scale(0);
font-size: 48px;
font-weight: 800;
background: linear-gradient(135deg, #f5a0ff, #00f5a0);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
opacity: 0;
transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
text-shadow: none;
filter: drop-shadow(0 0 30px rgba(0,245,160,0.5));
}
#combo.show {
transform: translate(-50%, -50%) scale(1);
opacity: 1;
}
#instructions {
position: absolute;
bottom: 130px;
left: 50%;
transform: translateX(-50%);
font-size: 14px;
color: rgba(255,255,255,0.5);
text-align: center;
transition: opacity 0.3s;
}
#gameOver {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: rgba(10,10,20,0.95);
backdrop-filter: blur(30px);
opacity: 0;
visibility: hidden;
transition: all 0.5s ease;
}
#gameOver.show {
opacity: 1;
visibility: visible;
}
#gameOver h1 {
font-size: 36px;
color: rgba(255,255,255,0.6);
margin-bottom: 20px;
font-weight: 400;
}
#gameOver .finalScore {
font-size: 100px;
font-weight: 800;
background: linear-gradient(135deg, #667eea, #764ba2, #f5a0ff);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
margin-bottom: 10px;
line-height: 1;
}
#gameOver .newRecord {
font-size: 18px;
color: #00f5a0;
margin-bottom: 10px;
opacity: 0;
transform: translateY(10px);
transition: all 0.5s ease 0.3s;
}
#gameOver.show .newRecord.visible {
opacity: 1;
transform: translateY(0);
}
#gameOver .bestScore {
font-size: 16px;
color: rgba(255,255,255,0.5);
margin-bottom: 50px;
}
#restartBtn {
padding: 18px 70px;
font-size: 18px;
font-weight: 600;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 50px;
cursor: pointer;
pointer-events: auto;
transition: all 0.3s ease;
box-shadow: 0 10px 40px rgba(102,126,234,0.4);
}
#restartBtn:hover {
transform: translateY(-3px) scale(1.05);
box-shadow: 0 20px 50px rgba(102,126,234,0.5);
}
#restartBtn:active {
transform: translateY(0) scale(0.98);
.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0