堆叠游戏 - 使用 Three.js + Cannon.jsedit icon

创建者:
用户zdlDCoL7
Fork(复制)
下载
嵌入
BUG反馈
index.html
main.js
package.json
style.css
index.html
            
            <!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>亲爱的赵洋,生日快乐!</title>
    <style>
        body {
            font-family: 'Arial', sans-serif;
            background-color: #ffebee;
            text-align: center;
            margin: 0;
            padding: 0;
            overflow-x: hidden;
            transition: background-color 0.5s;
        }
        
        .container {
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
        }
        
        h1 {
            color: #e91e63;
            font-size: 3em;
            margin-bottom: 20px;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
        }
        
        .message {
            background-color: white;
            border-radius: 15px;
            padding: 20px;
            margin: 20px 0;
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
            font-size: 1.2em;
            line-height: 1.6;
        }
        
        .dog-container {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 20px;
            margin: 30px 0;
        }
        
        .dog {
            width: 150px;
            height: 150px;
            background-size: cover;
            background-position: center;
            border-radius: 50%;
            cursor: pointer;
            transition: transform 0.3s;
            box-shadow: 0 4px 8px rgba(0,0,0,0.2);
        }
        
        .dog:hover {
            transform: scale(1.1) rotate(5deg);
        }
        
        .cake {
            font-size: 5em;
            cursor: pointer;
            margin: 20px 0;
            animation: float 3s ease-in-out infinite;
        }
        
        .hidden-message {
            display: none;
            background-color: #e91e63;
            color: white;
            padding: 15px;
            border-radius: 10px;
            margin: 20px 0;
            animation: fadeIn 1s;
        }
        
        button {
            background-color: #e91e63;
            color: white;
            border: none;
            padding: 12px 25px;
            font-size: 1.2em;
            border-radius: 50px;
            cursor: pointer;
            transition: all 0.3s;
            margin: 10px;
            box-shadow: 0 4px 8px rgba(0,0,0,0.2);
        }
        
        button:hover {
            background-color: #c2185b;
            transform: translateY(-3px);
            box-shadow: 0 6px 12px rgba(0,0,0,0.3);
        }
        
        @keyframes float {
            0% { transform: translateY(0px); }
            50% { transform: translateY(-15px); }
            100% { transform: translateY(0px); }
        }
        
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }
        
        .hearts {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 100;
        }
        
        .heart {
            position: absolute;
            font-size: 20px;
            color: #e91e63;
            animation: float-up 4s linear forwards;
        }
        
        @keyframes float-up {
            to {
                transform: translateY(-100vh);
                opacity: 0;
            }
        }
        
        .confetti {
            position: fixed;
            width: 10px;
            height: 10px;
            background-color: #f00;
            opacity: 0;
            z-index: 99;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>赵洋,生日快乐!🎉</h1>
        
        <div class="message">
            <p>亲爱的洋,</p>
            <p>在这个特别的日子里,我想告诉你...</p>
            <p>你是世界上最棒的女生!✨</p>
            <p>愿你的生日充满欢乐、惊喜和可爱的小狗!🐶</p>
        </div>
        
        <div class="cake" onclick="showCakeMessage()">🎂</div>
        
        <div id="cakeMessage" class="hidden-message">
            许个愿吧!愿你的所有梦想都能实现!✨
        </div>
        
        <h2>送给你一些可爱的小狗!</h2>
        <div class="dog-container">
            <div class="dog" style="background-image: url('https://placedog.net/300/300?random=1');" onclick="bark(this)"></div>
            <div class="dog" style="background-image: url('https://placedog.net/300/300?random=2');" onclick="bark(this)"></div>
            <div class="dog" style="background-image: url('https://placedog.net/300/300?random=3');" onclick="bark(this)"></div>
            <div class="dog" style="background-image: url('https://placedog.net/300/300?random=4');" onclick="bark(this)"></div>
        </div>
        
        <button onclick="showLove()">点击表达爱意</button>
        <button onclick="startConfetti()">放烟花庆祝</button>
        
        <div id="loveMessage" class="hidden-message">
            赵洋,我爱你!❤️ 每一天都因为有你而更美好!
        </div>
    </div>
    
    <div class="hearts" id="hearts"></div>
    
    <script>
        function showCakeMessage() {
            const message = document.getElementById('cakeMessage');
            message.style.display = message.style.display === 'block' ? 'none' : 'block';
        }
        
        function bark(dog) {
            dog.style.transform = 'scale(1.1) rotate(5deg)';
            setTimeout(() => {
                dog.style.transform = 'scale(1)';
            }, 300);
            
            // Play bark sound
            const audio = new Audio('https://www.soundjay.com/mechanical/sounds/dog-bark-01.mp3');
            audio.play().catch(e => console.log('无法播放声音:', e));
            
            // Add a little "bark" text
            const barkText = document.createElement('div');
            barkText.textContent = '汪!';
            barkText.style.position = 'absolute';
            barkText.style.color = '#e91e63';
            barkText.style.fontWeight = 'bold';
            barkText.style.animation = 'fadeIn 1s, float-up 2s forwards';
            barkText.style.left = (dog.getBoundingClientRect().left + 50) + 'px';
            barkText.style.top = (dog.getBoundingClientRect().top - 20) + 'px';
            document.body.appendChild(barkText);
            
            setTimeout(() => {
                document.body.removeChild(barkText);
            }, 2000);
        }
        
        function showLove() {
            const message = document.getElementById('loveMessage');
            message.style.display = message.style.display === 'block' ? 'none' : 'block';
            
            // Create floating hearts
            const heartsContainer = document.getElementById('hearts');
            for (let i = 0; i < 50; i++) {
                setTimeout(() => {
                    const heart = document.createElement('div');
                    heart.className = 'heart';
                    heart.innerHTML = '❤️';
                    heart.style.left = Math.random() * 100 + 'vw';
                    heart.style.animationDuration = (Math.random() * 3 + 2) + 's';
                    heartsContainer.appendChild(heart);
                    
                    setTimeout(() => {
                        heartsContainer.removeChild(heart);
                    }, 4000);
                }, i * 100);
            }
        }
        
        function startConfetti() {
            // Create confetti
            for (let i = 0; i < 100; i++) {
                setTimeout(() => {
                    createConfetti();
                }, i * 30);
            }
        }
        
        function createConfetti() {
            const confetti = document.createElement('div');
            confetti.className = 'confetti';
            
            // Random color
            const colors = ['#e91e63', '#00bcd4', '#ffeb3b', '#4caf50', '#9c27b0'];
            confetti.style.backgroundColor = colors[Math.floor(Math.random() * colors.length)];
            
            // Random position
            confetti.style.left = Math.random() * 100 + 'vw';
            confetti.style.top = '-10px';
            
            // Random size
            const size = Math.random() * 10 + 5;
            confetti.style.width = size + 'px';
            confetti.style.height = size + 'px';
            
            // Random shape
            confetti.style.borderRadius = Math.random() > 0.5 ? '50%' : '0';
            
            document.body.appendChild(confetti);
            
            // Animate
            const animationDuration = Math.random() * 3 + 2;
            confetti.style.transition = `all ${animationDuration}s linear`;
            confetti.style.opacity = '1';
            
            setTimeout(() => {
                confetti.style.transform = `translateY(${window.innerHeight}px) rotate(${Math.random() * 360}deg)`;
                confetti.style.opacity = '0';
            }, 10);
            
            // Remove after animation
            setTimeout(() => {
                document.body.removeChild(confetti);
            }, animationDuration * 1000);
        }
        
        // Change background color periodically
        let colorIndex = 0;
        const colors = ['#ffebee', '#fff8e1', '#e8f5e9', '#e3f2fd', '#f3e5f5'];
        
        setInterval(() => {
            colorIndex = (colorIndex + 1) % colors.length;
            document.body.style.backgroundColor = colors[colorIndex];
        }, 3000);
    </script>
</body>
</html>
        
编辑器加载中
预览
控制台