js+css实现一个杀虫小游戏代码
代码语言:html
所属分类:游戏
代码描述:js+css实现一个杀虫小游戏代码,按左键喷洒杀虫剂。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
:root {
--title: "Fumigation Frenzy";
--author: "Matt Cannon";
--contact: "mc@mattcannon.design";
--description: "A fast-paced bug extermination game where you spray fumigation gas to eliminate bugs before your tank runs out.";
--keywords: "game, bugs, fumigation, extermination, spray, pest control, arcade game, particle effects, animation, CSS animation, JavaScript game, HTML5 game, interactive";
--last-modified: "2025-03-05";
--content-language: "en";
--generator: "HTML5, CSS3, JavaScript, FontAwesome icons, CSS particles, requestAnimationFrame for fumigation gas animation, dynamic particle system for gas clouds, CSS transforms for bug movement";
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
background: url(//repo.bfw.wiki/bfwrepo/image/67d76faf0f8f6.png);
cursor: none; /* Hide default cursor */
overflow: hidden;
font-family: 'Rubik', sans-serif;
color: #fff;
}
/* Make sure all elements use the 'none' cursor to properly hide it */
#root, button, div, .bug {
cursor: none;
}
#root { position: relative; height: 100vh; }
.cursor {
position: absolute;
width: 200px;
height: 300px;
background: url('//repo.bfw.wiki/bfwrepo/images/chong/wand.png');
background-size: contain;
background-position: center;
background-repeat: no-repeat;
pointer-events: none;
z-index: 1000; /* Increased z-index to ensure it's on top */
transform-origin: 50% 90%;
transition: transform 0.1s;
will-change: left, top; /* Optimize for animation performance */
}
.cursor.spray {
transform: scale(0.95);
animation: shake 0.1s infinite;
}
@keyframes shake {
0% { transform: rotate(-2deg) scale(0.95); }
50% { transform: rotate(2deg) scale(0.95); }
100% { transform: rotate(-2deg) scale(0.95); }
}
/* Gas cloud particle */
.gas-particle {
position: absolute;
border-radius: 50%;
background-color: rgba(0, 255, 0, 0.8);
pointer-events: none;
z-index: 90;
filter: blur(4px);
mix-blend-mode: screen;
box-shadow: 0 0 10px rgb(0, 255, 0);
}
/* Bug styles */
.bug {
position: absolute;
background-position: 0 0;
z-index: 50;
filter: drop-shadow(1px 1px 2px rgba(0,0,0,0.3));
transition: transform 0.3s;
}
.bug.dead {
animation: none !important;
transition: top 0.8s cubic-bezier(0.5, 0, 1, 0.5);
top: calc(100% + 30px) !important;
transform: rotate(180deg);
opacity: 0.6;
z-index: 40;
}
.fly {
width: 26px; height: 16px;
animation: fly 0.1s infinite step-end;
background: url(//repo.bfw.wiki/bfwrepo/images/chong/fly.png);
}
.gnat {
width: 14px; height: 10px;
animation: gnat 0.1s infinite step-end;
background: url(//repo.bfw.wiki/bfwrepo/images/chong/gnat.png);
}
.wasp {
width: 48px; height: 32px;
animation: wasp 0.1s infinite step-end;
background: url(//repo.bfw.wiki/bfwrepo/images/chong/wasp.png);
}
.bigfly {
width: 32px; height: 30px;
animation: bigfly 0.1s infinite step-end;
background: url(//repo.bfw.wiki/bfwrepo/images/chong/bigfly.png);
}
@keyframes fly { 0% { background-position: 0 0; } 50% { background-position: -26px 0; } }
@keyframes gnat { 0% { background-position: -14px 0; } 50% { background-position: -28px 0; } }
@keyframes wasp { 0% { background-position: -96px 0; } 50% { background-position: -144px 0; } }
@keyframes bigfly { 0% { background-position: 0 0; } 50% { background-position: -32px 0; } }
@keyframes float-up { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(-40px); opacity: 0; } }
/* UI Elements */
.stats-container {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.5);
color: #fff;
padding: 10px 15px;
font-weight: bold;
font-size: 20px;
z-index: 200;
display: flex;
align-items: center;
}
.stats-container i {
margin-right: 8px;
color: #90ee90;
}
.sta.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0