three实现三维3d消消乐游戏代码

代码语言:html

所属分类:游戏

代码描述:three实现三维3d消消乐游戏代码

代码标签: three 三维 3d 消消乐 游戏 代码

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

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/three.139.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/tween.umd.js"></script>
  <style>
    /* --- CSS Variables and Basic Reset --- */
    :root {
      --primary-color: #4CAF50;
      --secondary-color: #007bff;
      --danger-color: #f44336;
      --background-color: #000033;
      --light-text: #ffffff;
      --dark-text: #333333;
      --overlay-bg: rgba(0, 0, 0, 0.85);
      --win-overlay-bg: rgba(20, 100, 20, 0.9);
    }

    body {
      margin: 0;
      overflow: hidden;
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
      background-color: var(--background-color);
      color: var(--light-text);
      position: fixed;
      width: 100%;
      height: 100%;
    }

    /* --- Screen Management --- */
    .screen {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      display: none;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 20px;
      box-sizing: border-box;
      background-color: var(--background-color);
      transition: opacity 0.5s ease;
      opacity: 0;
    }

    .screen.active {
      display: flex;
      opacity: 1;
    }

    /* --- Splash Screen Styling --- */
    #splash-screen {
      background: radial-gradient(circle at center, #6b46c1 0%, #3b82f6 25%, #6b46c1 50%, #3b82f6 75%, #6b46c1 100%);
      background-size: 100% 100%;
      position: relative;
      overflow: hidden;
    }

    #splash-screen::before {
      content: '';
      position: absolute;
      top: 50%;
      left: 50%;
      width: 200%;
      height: 200%;
      background: conic-gradient(
        from 0deg,
        #6b46c1 0deg 22.5deg,
        #3b82f6 22.5deg 45deg,
        #6b46c1 45deg 67.5deg,
        #3b82f6 67.5deg 90deg,
        #6b46c1 90deg 112.5deg,
        #3b82f6 112.5deg 135deg,
        #6b46c1 135deg 157.5deg,
        #3b82f6 157.5deg 180deg,
        #6b46c1 180deg 202.5deg,
        #3b82f6 202.5deg 225deg,
        #6b46c1 225deg 247.5deg,
        #3b82f6 247.5deg 270deg,
        #6b46c1 270deg 292.5deg,
        #3b82f6 292.5deg 315deg,
        #6b46c1 315deg 337.5deg,
        #3b82f6 337.5deg 360deg
      );
      transform: translate(-50%, -50%);
      z-index: 1;
      animation: rotate 20s linear infinite;
    }

    @keyframes rotate {
      from { transform: translate(-50%, -50%) rotate(0deg); }
      to { transform: translate(-50%, -50%) rotate(360deg); }
    }

    /* 3D Canvas for splash screen */
    #splash-3d-container {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: 2;
      pointer-events: none;
    }

    .splash-content {
      position: relative;
      z-index: 10;
      text-align: center;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      width: 100%;
      max-width: 500px;
    }

    .title-container {
        text-align: center;
        margin-bottom: 40px;
        position: relative;
        z-index: 10;
        width: 100%;
    }

    .splash-title {
      font-size: clamp(2.5rem, 10vw, 4.5rem);
      font-weight: 900;
      color: #ffffff;
      text-shadow: 
        4px 4px 0px #000000,
        -4px -4px 0px #000000,
        4px -4px 0px #000000,
        -4px 4px 0px #000000,
        6px 6px 10px rgba(0, 0, 0, 0.8);
      letter-spacing: 0.05em;
      margin: 0;
      line-height: 0.9;
    }

    .splash-subtitle {
      font-size: clamp(1rem, 4vw, 1.5rem);
      color: #ffffff;
      margin-top: 10px;
      margin-bottom: 0;
      text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
      font-weight: 600;
    }

    .menu-container {
      width: 100%;
      max-width: 380px;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 15px;
      position: relative;
      z-index: 10;
      margin: 0 auto;
    }

    .btn {
      padding: 18px 24px;
      border-radius: 15px;
      border: 4px solid #000000;
      color: #ffffff;
      cursor: pointer;
      font-size: 1.4rem;
      font-weight: 900;
      text-transform: uppercase;
      transition: transform 0.2s ease, background-color 0.3s ease, border-color 0.3s ease;
      text-shadow: 2px 2px 0px #000000;
      letter-spacing: 0.1em;
      position: relative;
      overflow: hidden;
      pointer-events: all;
      width: 100%;
      max-width: 280px;
      text-align: center;
    }

    .btn:hover {
        transform: translateY(-3px) scale(1.05);
    }

    .btn:active {
      transform: scale(0.96) translateY(0);
    }

    .btn-primary {
      background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
      border-color: #000000;
      box-shadow: 0 6px 0 #92400e, 0 8px 15px rgba(0, 0, 0, 0.3);
    }

    .btn-primary:hover {
      box-shadow: 0 8px 0 #92400e, 0 12px 20px rgba(0, 0, 0, 0.4);
    }

    .btn-secondary {
      background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
      border-color: #000000;
      box-shadow: 0 6px 0 #1e3a8a, 0 8px 15px rgba(0, 0, 0, 0.3);
    }

    .btn-secondary:hover {
      box-shadow: 0 8px 0 #1e3a8a, 0 12px 20px rgba(0, 0, 0, 0.4);
    }

    .btn-danger {
      background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
      border-color: #000000;
      box-shadow: 0 6px 0 #991b1b, 0 8px 15px rgba(0, 0, 0, 0.3);
    }

    .btn-danger:hover {
      box-shadow: 0 8px 0 #991b1b, 0 12px 20px rgba(0, 0, 0, 0.4);
    }

    /* Floating CSS Shapes (smaller and fewer to complement 3D shapes) */
    .floating-shapes {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      pointer-events: none;
      z-index: 3;
    }

    .floating-shape {
      position: absolute;
      animation: float 8s ease-in-out infinite;
      opacity: 0.6;
    }

    .floating-shape:nth-child(2n) {
      animation-direction: reverse;
      animation-duration: 10s;
    }

    .floating-shape:nth-child(3n) {
      animation-delay: -3s;
    }

    .floating-shape:nth-child(4n) {
      animation-delay: -6s;
    }

    @keyframes float {
      0%, 100% { transform: translateY(0px) rotate(0deg) scale(1); }
      33% { transform: translateY(-30px) rotate(120deg) scale(1.1); }
      66% { transform: translateY(15px) rotate(240deg) scale(0.9); }
    }

    .shape-circle {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      border: 6px solid;
    }

    .shape-square {
      width: 35px;
      height: 35px;
      border: 6px solid;
      border-radius: 6px;
    }

    .shape-triangle {
      width: 0;
      height: 0;
      border-left: 20px solid transparent;
      border-right: 20px solid transparent;
      border-bottom: 35px solid;
    }

    .color-red { border-color: #ef4444; }
    .color-blue { border-color: #3b82f6; }
    .color-green { border-color: #10b981; }
    .color-yellow { border-color: #fbbf24; }
    .color-purple { border-color: #8b5cf6; }
    .color-orange { border-color: #f97316; }

    .color-red.shape-triangle { border-bottom-color: #ef4444; border-left-color: transparent; border-right-color: transparent; }
    .color-blue.shape-triangle { border-bottom-color: #3b82f6; border-left-color: transparent; border-right-color: transparent; }
    .color-green.shape-triangle { border-bottom-color: #10b981; border-left-color: transparent; border-right-color: transparent; }

    /* --- Settings Screen Specific --- */
    #settings-screen .menu-container {
      background-color: rgba(0, 0, 0, 0.8);
      padding: 30px;
      border-radius: 15px;
      box-shadow: 0 4px 20px rgba(0,0,0,0.3);
      border: 4px solid #ffffff;
    }

    .setting-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 15px;
    }

    .setting-item label {
      font-size: 1.1rem;
      font-weight: 600;
    }

    .setting-item select {
      padding: 10px;
      border-radius: 8px;
      border: 2px solid #000000;
      background-color: #ffffff;
      color: #000000;
      font-size: 1rem;
      font-weight: 600;
      width: 100px;
      text-align: center;
    }

    /* --- Game Screen & UI --- */
    #game-screen {
      padding: 0;
      cursor: default;
    }

    #container {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
    }

    #game-ui {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      z-index: 100;
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      padding: 20px;
      pointer-events: none;
    }

    .rotation-controls {
      display: flex;
      flex-direction: row;
      gap: 10px;
      pointer-events: all;
    }

    .rotate-btn {
      width: 50px;
      height: 50px;
      border-radius: 50%;
      background-color: rgba(0, 0, 0, 0.7);
      color: var(--light-text);
      border: 2px solid rgba(255, 255, 255, 0.3);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 1.5rem;
      font-weight: bold;
      transition: all 0.2s ease;
      text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    }

    .rotate-btn:hover {
      transform: scale(1.1);
      background-color: rgba(0, 0, 0, 0.9);
      border-color: rgba(255, 255, 255, 0.6);
    }

    .rotate-btn:active {
      transform: scale(0.95);
    }

    .rotate-btn:disabled {
      opacity: 0.5;
      cursor: not-allowed;
      transform: none;
    }

    #game-menu-btn,
    #game-score {
      pointer-events: all;
      font-size: clamp(1.2rem, 5vw, 1.8rem);
      font-weight: bold;
      color: var(--light-text);
      background-color: rgba(0, 0, 0, 0.5);
  .........完整代码请登录后点击上方下载按钮下载查看

网友评论0