three实现3d桌面贪吃蛇游戏代码

代码语言:html

所属分类:游戏

代码描述:three实现3d桌面贪吃蛇游戏代码

代码标签: three 3d 桌面 贪吃蛇 游戏 代码

下面为部分代码预览,完整代码请点击下载或在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>Three.js 3D 贪吃蛇</title>
  <style>
    * {
      box-sizing: border-box;
      -webkit-tap-highlight-color: transparent;
    }

    html, body {
      margin: 0;
      width: 100%;
      height: 100%;
      overflow: hidden;
      background:
        radial-gradient(circle at top, #1e293b 0%, #0f172a 45%, #020617 100%);
      font-family: Arial, "Microsoft YaHei", sans-serif;
      color: #e2e8f0;
    }

    body {
      position: relative;
    }

    #hud {
      position: fixed;
      top: 14px;
      left: 14px;
      z-index: 10;
      width: min(360px, calc(100vw - 28px));
      padding: 14px 16px;
      border-radius: 18px;
      background: rgba(15, 23, 42, 0.68);
      border: 1px solid rgba(148, 163, 184, 0.22);
      box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
      backdrop-filter: blur(10px);
      user-select: none;
    }

    #hud .title {
      font-size: 22px;
      font-weight: 700;
      margin-bottom: 10px;
      color: #f8fafc;
      letter-spacing: 1px;
    }

    #hud .stats {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 10px;
      margin-bottom: 10px;
    }

    #hud .card {
      padding: 10px 10px 8px;
      border-radius: 14px;
      background: rgba(30, 41, 59, 0.72);
      border: 1px solid rgba(148, 163, 184, 0.12);
    }

    #hud .label {
      font-size: 12px;
      color: #94a3b8;
      margin-bottom: 4px;
    }

    #hud .value {
      font-size: 22px;
      font-weight: 700;
      color: #f8fafc;
    }

    #statusText {
      margin: 8px 0 10px;
      color: #cbd5e1;
      font-size: 14px;
      line-height: 1.6;
    }

    #hud .actions {
      display: flex;
      gap: 10px;
      margin-bottom: 10px;
    }

    #hud button {
      appearance: none;
      border: 0;
      cursor: pointer;
      border-radius: 12px;
      padding: 10px 14px;
      font-size: 14px;
      font-weight: 700;
      color: #f8fafc;
      background: linear-gradient(180deg, #22c55e, #16a34a);
      box-shadow: 0 10px 20px rgba(34, 197, 94, 0.22);
    }

    #pauseBtn {
      background: linear-gradient(180deg, #3b82f6, #2563eb) !important;
      box-shadow: 0 10px 20px rgba(59, 130, 246, 0.22) !important;
    }

    #hud .tips {
      font-size: 13px;
      line-height: 1.7;
      color: #94a3b8;
    }

    #centerMessage {
      position: fixed;
      inset: 0;
      z-index: 9;
      display: flex;
      align-items: center;
      justify-content: center;
      pointer-events: none;
      opacity: 0;
      transition: opacity 0.25s ease;
    }

    #centerMessage.show {
      opacity: 1;
    }

    #centerMessage .panel {
      min-width: min(420px, calc(100vw - 3.........完整代码请登录后点击上方下载按钮下载查看

网友评论0