原生js+css实现鼠标抓住移动闪烁的小点游戏代码
代码语言:html
所属分类:游戏
代码描述:原生js+css实现鼠标抓住移动闪烁的小点游戏代码
代码标签: 原生 js css 鼠标 抓住 移动 闪烁 小点 游戏 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
user-select: none;
}
:root {
--primary-color: #f0d6e8;
--secondary-color: #c1e8f8;
--accent-color: #a5b9ea;
--dark-accent: #9985c9;
--warning-color: #ff96ad;
--success-color: #96ffbc;
--background-dark: #2a2e45;
--background-light: #3d4263;
--text-color: #e0e5ff;
--health-good: #96ffbc;
--health-mid: #fff596;
--health-low: #ff96ad;
}
body, html {
width: 100%;
height: 100%;
overflow: hidden;
font-family: 'Cyberpunk', sans-serif;
background-color: var(--background-dark);
cursor: none;
}
.game-container {
position: relative;
width: 100%;
height: 100%;
background: linear-gradient(135deg, var(--background-dark), var(--background-light));
overflow: hidden;
}
.game-container::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-image:
linear-gradient(90deg, rgba(26, 29, 48, 0.3) 1px, transparent 1px),
linear-gradient(rgba(26, 29, 48, 0.3) 1px, transparent 1px),
linear-gradient(0deg, rgba(90, 100, 150, 0.1) 1px, transparent 1px),
background-size:
50px 50px,
50px 50px,
50px 50px,
200px 200px;
opacity: 0.6;
z-index: 0;
animation: backgroundPulse 10s infinite alternate;
}
@keyframes backgroundPulse {
0% {
background-position:
0 0,
0 0,
0 0,
0 0;
}
100% {
background-position:
20px 0,
0 20px,
-20px 0,
40px 40px;
}
}
.game-container::after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-image:
radial-gradient(circle at 50% 50%, var(--secondary-color) 0%, transparent 8%),
linear-gradient(90deg, transparent 95%, var(--accent-color) 95%),
linear-gradient(0deg, transparent 95%, var(--accent-color) 95%);
background-size: 300px 300px, 100px 100px, 100px 100px;
z-index: 0;
opacity: 0.15;
animation: circuitPulse 15s infinite linear;
}
@keyframes circuitPulse {
0% {
opacity: 0.05;
background-position: 0 0, 0 0, 0 0;
}
50% {
opacity: 0.2;
}
100% {
opacity: 0.05;
background-position: 300px 300px, 100px 100px, 100px 100px;
}
}
.health-container {
position: absolute;
top: 5vh;
left: 50%;
transform: translateX(-50%);
width: 40vw;
z-index: 10;
text-align: center;
}
.health-bar {
height: 3vh;
width: 100%;
background-color: rgba(30, 34, 59, 0.7);
border-radius: 15px;
padding: 3px;
box-shadow:
0 0 0 2px rgba(255, 255, 255, 0.1),
0 0 10px rgba(0, 0, 0, 0.3),
inset 0 0 15px rgba(0, 0, 0, 0.3);
position: relative;
overflow: hidden;
}
.health-fill {
height: 100%;
width: 100%;
background: linear-gradient(90deg, var(--health-good), var(--success-color));
border-radius: 12px;
transition: width 0.3s ease, background 0.5s ease;
position: relative;
box-shadow: 0 0 10px var(--health-good);
}
.health-fill::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
animation: healthPulse 2s infinite;
}
@keyframes healthPulse {
0% { transform: translateX(-100%); }
100% { transform: translateX(100%); }
}
.health-text {
margin-top: 1vh;
font-size: 2.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0