js实现沙漏瓶子游戏代码

代码语言:html

所属分类:游戏

代码描述:js实现沙漏瓶子游戏代码

代码标签: js 沙漏 瓶子 游戏 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>沙漏瓶子 - Sand Drop</title>
<style>
  * { margin: 0; padding: 0; box-sizing: border-box; }
  
  body {
    background: #1a0f00;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    font-family: 'Segoe UI', sans-serif;
    overflow: hidden;
    user-select: none;
  }

  #gameWrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  /* 顶部信息栏 */
  #hud {
    display: flex;
    gap: 24px;
    align-items: center;
    background: rgba(255,200,80,0.08);
    border: 1px solid rgba(255,200,80,0.2);
    border-radius: 12px;
    padding: 10px 24px;
  }

  .hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
  }

  .hud-label {
    font-size: 10px;
    color: rgba(255,200,80,0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
  }

  .hud-value {
    font-size: 22px;
    font-weight: 700;
    color: #ffd04d;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 12px rgba(255,200,80,0.6);
    min-width: 60px;
    text-align: center;
  }

  .hud-divider {
    width: 1px;
    height: 36px;
    background: rgba(255,200,80,0.2);
  }

  /* 画布容器 */
  #canvasWrap {
    position: relative;
    cursor: crosshair;
  }

  #gameCanvas {
    display: block;
    border-radius: 8px;
  }

  /* 沙子倾倒提示 */
  #pourHint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    transition: opacity 0.4s;
  }

  #pourHint .hint-icon {
    font-size: 40px;
    animation: bounce 1.2s ease-in-out infinite;
  }

  #pourHint .hint-text {
    color: rgba(255,200,80,0.6);
    font-size: 13px;
    margin-top: 6px;
  }

  @keyframes bounce {
    0%,100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
  }

  /* 难度与关卡选择 */
  #levelBar {
    display: flex;
    gap: 8px;
  }

  .level-btn {
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255,200,80,0.3);
    background: transparent;
    color: rgba(255,200,80,0.5);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
  }

  .level-btn:hover, .level-btn.active {
    background: rgba(255,200,80,0.15);
    border-color: rgba(255,200,80,0.7);
    color: #ffd04d;
  }

  /* 覆盖层:结算/失败 */
  #overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.75);
    border-radius: 8px;
    flex-direction: column;
    align-items: center;
    justify-content.........完整代码请登录后点击上方下载按钮下载查看

网友评论0