canvas实现街头打篮球灌篮投篮游戏代码
代码语言:html
所属分类:游戏
代码描述:canvas实现街头打篮球灌篮投篮游戏代码
代码标签: canvas 街头 打 篮球 灌篮 投篮 游戏 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>篮球投篮大师</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Microsoft YaHei', Arial, sans-serif;
background: linear-gradient(to bottom, #87ceeb 0%, #e0f6ff 100%);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
overflow: hidden;
position: relative;
}
/* 云朵背景 */
.cloud {
position: absolute;
background: rgba(255, 255, 255, 0.6);
border-radius: 100px;
animation: float 20s infinite ease-in-out;
}
.cloud:before, .cloud:after {
content: '';
position: absolute;
background: rgba(255, 255, 255, 0.6);
border-radius: 100px;
}
.cloud1 {
width: 100px;
height: 40px;
top: 10%;
left: 10%;
}
.cloud1:before {
width: 50px;
height: 50px;
top: -25px;
left: 10px;
}
.cloud1:after {
width: 60px;
height: 40px;
top: -15px;
right: 10px;
}
.cloud2 {
width: 120px;
height: 50px;
top: 20%;
right: 15%;
animation-delay: -5s;
}
.cloud2:before {
width: 60px;
height: 60px;
top: -30px;
left: 20px;
}
.cloud2:after {
width: 70px;
height: 50px;
top: -20px;
right: 15px;
}
@keyframes float {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-20px); }
}
.game-container {
position: relative;
background: rgba(255, 255, 255, 0.9);
border-radius: 20px;
padding: 20px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
canvas {
display: block;
background: linear-gradient(to bottom, #87ceeb 0%, #c9b59a 70%, #8b7355 100%);
border-radius: 15px;
box-shadow: inset 0 5px 20px rgba(0, 0, 0, 0.2);
cursor: pointer;
}
.ui-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
}
/* 顶部信息栏 */
.top-bar {
position: absolute;
top: 30px;
width: 100%;
display: flex;
justify-content: space-around;
padding: 0 40px;
}
.info-box {
background: rgba(0, 0, 0, 0.8);
color: white;
padding: 15px 25px;
border-radius: 15px;
text-align: center;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}
.info-label {
font-size: 14px;
opacity: 0.8;
margin-bottom: 5px;
}
.info-value {
font-size: 32px;
font-weight: bold;
color: #ffd700;
text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}
.timer {
color: #ff4444;
}
.timer.warning {
animation: pulse 0.5s infinite;
}
@keyframes pulse {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.1); }
}
/* 力量条 */
.power-bar-container {
position: absolute;
bottom: 100px;
left: 50px;
width: 40px;
height: 300px;
background: rgba(0, 0, 0, 0.3);
border-radius: 20px;
border: 3px solid rgba(255, 255, 255, 0.5);
display: none;
}
.power-bar-fill {
position: absolute;
bottom: 0;
width: 100%;
height: 0%;
background: linear-gradient(to top, #00ff00, #ffff00, #ff0000);
border-radius: 17px.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0