js+css实现小船河流行驶避障类游戏代码
代码语言:html
所属分类:游戏
代码描述:js+css实现小船河流行驶避障类游戏代码
代码标签: js css 小船 河流 行驶 避障 游戏 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, viewport-fit=cover">
<title>河流漂筏 · 躲避障碍</title>
<style>
:root {
--safe-bottom: env(safe-area-inset-bottom, 0px);
}
html,
body {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
background: #1a3c4a;
overflow: hidden;
touch-action: manipulation;
-webkit-touch-callout: none;
-webkit-tap-highlight-color: transparent;
-webkit-user-select: none;
user-select: none;
font-family: 'Segoe UI', system-ui, sans-serif;
}
.game-wrapper {
position: relative;
width: 100vw;
height: 100vh;
height: 100dvh;
overflow: hidden;
}
canvas {
display: block;
width: 100%;
height: 100%;
cursor: pointer;
}
/* 移动端触摸提示 */
.touch-hint {
position: absolute;
bottom: calc(40px + var(--safe-bottom));
left: 50%;
transform: translateX(-50%);
display: flex;
gap: 60px;
pointer-events: none;
z-index: 20;
transition: opacity 0.8s ease;
}
.touch-hint.fading {
opacity: 0;
}
.touch-hint .hint-arrow {
width: 56px;
height: 56px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.18);
backdrop-filter: blur(8px);
display: flex;
align-items: center;
justify-content: center;
font-size: 28px;
color: rgba(255, 255, 255, 0.75);
animation: hintPulse 1.6s ease-in-out infinite;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
border: 1.5px solid rgba(255, 255, 255, 0.25);
}
.touch-hint .hint-arrow:nth-child(2) {
animation-delay: 0.3s;
}
@keyframes hintPulse {
0%,
100% {
transform: scale(1);
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
50% {
transform: scale(1.12);
box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
}
}
/* 游戏结束覆盖按钮 */
.restart-btn {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) scale(0);
z-index: 25;
pointer-events: none;
padding: 16px 38px;
border-radius: 50px;
border: 2px solid rgba(255, 255, 255, 0.7);
background: rgba(20, 50, 60, 0.85);
backdrop-filter: blur(16px);
color: #fff;
font-size: 1.3rem;
font-weight: 700;
letter-spacing: 0.04em;
cursor: pointer;
transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
opacity 0.3s ease;
opacity: 0;
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
white-space: nowrap;
}
.restart-btn.visible {
transform: translate(-50%, -50%) scale(1);
opacity: 1;
pointer-events: auto;
}
.restart-btn:hover {
background: rgba(30, 70, 85, 0.9);
border-color: #fff;
box-shadow: 0 24px 56px rgba(0, 0, 0, 0.5);
}
.restart-btn:active {
transform: translate(-50%, -50%) scale(0.94);
transition: transform 0.1s ease;
}
@media (max-width: 600px) {
.touch-hint {
gap: 40px;
bottom: calc(30px + var(--safe-bottom));
}
.touch-hint .hint-arrow {
width: 46px;
height: 46px;
font-size: 24px;
}
.restart-btn {
padding: 14px 30px;
font-size: 1.1rem;
}
}
</style>
</head>
<body translate="no">
<div class="game-wrapper" id="gameWrapper">
.........完整代码请登录后点击上方下载按钮下载查看















网友评论0