js实现植物大战僵尸游戏代码
代码语言:html
所属分类:其他
代码由minimax-m3.1-flash ai生成,可能有错误,仅供参考:点击查看提示词
代码描述:植物大战僵尸游戏
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>植物大战僵尸 · Plants vs Zombies</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
height: 100%;
background: radial-gradient(circle at 50% 0%, #24401f 0%, #101a0e 60%, #070b06 100%);
color: #f2f4e6;
font-family: "Trebuchet MS", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
overflow: hidden;
user-select: none;
}
#wrap {
position: relative;
width: 1000px;
height: 640px;
margin: 0 auto;
transform-origin: top center;
}
/* ---------- seed bank ---------- */
#top {
height: 84px;
display: flex;
align-items: center;
gap: 10px;
padding: 0 12px;
background: linear-gradient(#6d4b2a, #4a3018);
border: 3px solid #2e1d0d;
border-bottom: none;
border-radius: 10px 10px 0 0;
box-shadow: inset 0 2px 0 rgba(255,255,255,.12);
}
#sunBox {
width: 92px; height: 58px;
display: flex; align-items: center; gap: 6px;
background: #f6efcf;
border: 3px solid #b9a466;
border-radius: 8px;
padding: 0 8px;
color: #3a2b0c;
font-weight: 700;
font-size: 22px;
}
#sunBox canvas { width: 34px; height: 34px; }
#seedBank { display: flex; gap: 6px; flex: 1; }
.seed {
position: relative;
width: 72px; height: 84px;
border-radius: 6px 6px 3px 3px;
background: linear-gradient(#cbb37a, #9c8047);
border: 2px solid #6b5227;
cursor: pointer;
overflow: hidden;
transition: transform .08s ease;
}
.seed:hover { transform: translateY(-3px); }
.seed.sel { outline: 3px solid #ffe066; outline-offset: -3px; }
.seed.cold { filter: grayscale(.85) brightness(.65); }
.seed canvas { display: block; width: 68px; height: 56px; }
.seed .cost {
position: absolute; left: 0; right: 0; bottom: 0;
background: #f2e6bd; color: #2b1f06;
font-weight: 700; font-size: 14px; text-align: center;
border-top: 2px solid #6b5227;
}
.seed .cdmask {
position: absolute; left: 0; right: 0; top: 0;
background: rgba(20,20,20,.62);
pointer-events: none;
}
#shovel, #pause {
width: 58px; height: 66px; border-radius: 8px;
background: linear-gradient(#8c8c9c, #55555f);
border: 3px solid #2f2f36; cursor: pointer;
display: flex; align-items: center; justify-content: center;
}
#shovel canvas { width: 46px; height: 46px; }
#pause canvas { width: 34px; height: 34px; }
#shovel.sel { outline: 3px solid #ffd24a; }
/* ---------- lawn ---------- */
#lawnWrap { position: relative; border: 3px solid #2e1d0d; border-top: none; border-radius: 0 0 10px 10px; overflow: hidden; }
canvas { display: block; }
/* ---------- overlay ---------- */
#overlay {
position: fixed; inset: 0;
background: rgba(6,10,6,.78);
display: flex; align-items: center; justify-content: center;
flex-direction: column; gap: 14px; text-align: center;
z-index: 20; backdrop-filter: blur(2px);
}
#overlay.hide { display: none; }
#overlay h1 { font-size: 46px; letter-spacing: 2px; color: #ffe066; text-shadow: 0 4px 0 #6b3b12; }
#overlay h2 { font-size: 26px; color: #cfe8b0; }
#overlay p { max-width: 560px; line-height: 1.7; color: #d8e3c6; font-size: 15px; }
.btn {
margin-top: 8px; padding: 12px 30px; font-size: 20px; font-weight: 700;
border-radius: 10px; border: 3px solid #2b1d06; cursor: pointer;
background: linear-gradient(#ffd94f, #e09b18); color: #3a2405;
box-shadow: 0 5px 0 #7a4c08;
}
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #7a4c08; }
.keys { font-size: 14px; color: #b9c8a6; line-height: 1.9; }
.keys b { color: #ffe066; }
</style>
</head>
<body>
<div id="wrap">
<div id="top">
<div id="sunBox"><canvas id="sunIcon" width="68" height="68"></canvas><span id="sunCount">50</span&g.........完整代码请登录后点击上方下载按钮下载查看















网友评论0