js+css实现小船河流行驶避障类游戏代码
代码语言:html
所属分类:游戏
代码描述:js+css实现小船河流行驶避障类游戏代码
代码标签: js css 小船 河流 行驶 避障 游戏 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<title>小船躲避障碍物</title>
<style>
html, body {
margin: 0;
padding: 0;
background: #222;
font-family: "Microsoft YaHei", Arial, sans-serif;
overflow: hidden;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
#wrap {
position: relative;
width: 800px;
max-width: 100%;
}
canvas {
display: block;
width: 100%;
background: #87ceeb;
border-radius: 8px;
box-shadow: 0 10px 30px rgba(0,0,0,0.4);
cursor: none;
}
#hud {
position: absolute;
top: 10px;
left: 12px;
color: #fff;
font-weight: bold;
text-shadow: 1px 1px 3px rgba(0,0,0,0.6);
pointer-events: none;
font-size: 16px;
}
#hud .score { font-size: 22px; }
#hud .dist { font-size: 14px; opacity: 0.9; }
#overlay {
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: #fff;
text-shadow: 2px 2px 6px rgba(0,0,0,0.7);
text-align: center;
background: rgba(0,0,0,0.25);
border-radius: 8px;
pointer-events: none;
}
#overlay h1 {
font-size: 42px;
margin: 0 0 8px;
letter-spacing: 2px;
}
#overlay p {
margin: 4px 0;
font-size: 16px;
opacity: 0.95;
}
#overlay .key { color: #ffe082; font-weight: bold; }
.hide { display: none !important; }
#info {
position: absolute;
bottom: 10px;
left: 12px;
color: #fff;
font-size: 12px;
opacity: 0.7;
text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}
</style>
</head>
<body>
<div id="wrap">
<canvas id="game" width="800" height="500"></canvas>
<div id="hud">
<div class="score">得分: <span id="score">0</span></div>
<div class="dist">距离: <span id="dist">0.........完整代码请登录后点击上方下载按钮下载查看















网友评论0