Skip to content
The Chat Archive
gemini-2.5-pro-preview-03-25· Google LMArena Human Preference 140K

Create a Pasta maker game for mobile give me all single html code

  1. User

    Create a Pasta maker game for mobile give me all single html code

  2. Assistant

    Okay, here is a simple Pasta Maker game contained entirely within a single HTML file. This game focuses on the core steps: selecting ingredients, mixing, kneading, rolling, and cutting. It uses basic HTML, CSS for styling, and JavaScript for interactivity.

    Key Features:

    • Single File: All code (HTML, CSS, JS) is in one file.
    • Mobile Friendly: Uses viewport meta tag and basic responsive CSS.
    • Step-by-Step: Guides the player through simplified pasta-making stages.
    • Interactive: Uses buttons and simple visual feedback.
    • Emoji Graphics: Uses emojis for simplicity and visual appeal without needing external images.

    Limitations:

    • Very Simple: No complex animations, drag-and-drop, or physics.
    • Basic Styling: Visuals are functional but not highly polished.
    • No Saving: Progress isn't saved.
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
        <title>Pasta Master 🍝</title>
        <style>
            /* Basic Reset & Body Styles */
            * {
                box-sizing: border-box;
                margin: 0;
                padding: 0;
            }
    
            html, body {
                height: 100%;
                font-family: 'Arial', sans-serif;
                background-color: #f0e4d0; /* Light beige background */
                color: #4a3f35; /* Dark brown text */
                overscroll-behavior: none; /* Prevent pull-to-refresh */
                touch-action: manipulation; /* Optimize touch interactions */
            }
    
            /* Game Container */
            #game-container {
                max-width: 500px;
                min-height: 95vh; /* Use viewport height */
                margin: 10px auto;
                padding: 20px;
                background-color: #fffaf0; /* Creamy white */
                border-radius: 15px;
                box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
                display: flex;
                flex-direction: column;
                align-items: center;
                text-align: center;
            }
    
            /* Stages Styling */
            .stage {
                display: none; /* Hide stages by default */
                width: 100%;
                padding: 15px;
                flex-grow: 1; /* Allow stage to fill space */
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: center;
            }
    
            .stage.active {
                display: flex; /* Show active stage */
            }
    
            h1 {
                color: #d98c5f; /* Muted orange */
                margin-bottom: 20px;
                font-size: 1.8em;
            }
    
            h2 {
                color: #7a6a5a; /* Taupe */
                margin-bottom: 25px;
                font-size: 1.4em;
            }
    
            p {
                margin-bottom: 15px;
                line-height: 1.5;
                font-size: 1em;
            }
    
            /* Buttons */
            button {
                background-color: #8b7d6b; /* Darker taupe */
                color: white;
                border: none;
                padding: 12px 25px;
                font-size: 1.1em;
                border-radius: 8px;
                cursor: pointer;
                transition: background-color 0.2s ease, transform 0.1s ease;
                margin-top: 15px;
                min-width: 150px;
            }
    
            button:hover, button:focus {
                background-color: #6a5a4a; /* Darken on hover */
                outline: none;
            }
    
            button:active {
                transform: scale(0.95);
            }
    
            button:disabled {
                background-color: #cccccc;
                cursor: not-allowed;
            }
    
            /* Interactive Elements */
            .ingredient-options, .shape-options {
                display: flex;
                flex-wrap: wrap;
                justify-content: center;
                gap: 15px;
                margin-bottom: 20px;
            }
    
            .option {
                font-size: 2.5em; /* Larger emojis */
                padding: 10px;
                background-color: #fdf5e6; /* Very light cream */
                border-radius: 10px;
                cursor: pointer;
                transition: transform 0.2s ease, box-shadow 0.2s ease;
                border: 2px solid transparent;
                min-width: 60px; /* Ensure tappable area */
                min-height: 60px;
                display: inline-flex;
                justify-content: center;
                align-items: center;
            }
    
            .option:hover {
                transform: scale(1.1);
                box-shadow: 0 2px 5px rgba(0,0,0,0.1);
            }
    
            .option.selected {
                border: 2px solid #d98c5f;
                background-color: #ffe8cc;
            }
    
            /* Visual Representations */
            .visual {
                font-size: 5em; /* Large emoji for visuals */
                margin: 20px 0;
                animation: pulse 1.5s infinite ease-in-out;
            }
    
            @keyframes pulse {
                0% { transform: scale(1); }
                50% { transform: scale(1.05); }
                100% { transform: scale(1); }
            }
    
            /* Progress Bar (Simple Simulation) */
            .progress-bar-container {
                width: 80%;
                height: 20px;
                background-color: #e0e0e0;
                border-radius: 10px;
                margin: 20px 0;
                overflow: hidden;
            }
    
            .progress-bar {
                width: 0%;
                height: 100%;
                background-color: #76c7c0; /* Teal color */
                border-radius: 10px;
                transition: width 0.5s ease-in-out;
            }
    
            /* Final Pasta Display */
            #final-pasta-display {
                font-size: 4em;
                margin-top: 20px;
            }
    
        </style>
    </head>
    <body>
    
        <div id="game-container">
            <h1>Pasta Master 🍝</h1>
    
            <!-- Stage 1: Ingredients -->
            <div id="stage-ingredients" class="stage active">
                <h2>Step 1: Gather Ingredients</h2>
                <p>Select your key ingredients:</p>
                <div class="ingredient-options">
                    <div class="option" data-ingredient="flour">🌾</div>
                    <div class="option" data-ingredient="egg">🥚</div>
                    <div class="option" data-ingredient="water">💧</div>
                </div>
                <p><span id="selected-ingredients-count">0</span>/3 selected</p>
                <button id="mix-button" disabled>Mix Ingredients</button>
            </div>
    
            <!-- Stage 2: Mixing -->
            <div id="stage-mixing" class="stage">
                <h2>Step 2: Mixing the Dough</h2>
                <p>Combine everything into a rough dough!</p>
                <div class="visual">🥣</div>
                <button id="start-mixing-button">Start Mixing</button>
                <div class="progress-bar-container" style="display: none;">
                    <div id="mixing-progress" class="progress-bar"></div>
                </div>
                <button id="knead-button" style="display: none;">Knead the Dough</button>
            </div>
    
            <!-- Stage 3: Kneading -->
            <div id="stage-kneading" class="stage">
                <h2>Step 3: Kneading Time!</h2>
                <p>Tap the button repeatedly to knead the dough until smooth.</p>
                <div class="visual" id="kneading-visual">✊</div>
                <button id="knead-action-button">Knead (0/10)</button>
                <div class="progress-bar-container">
                    <div id="kneading-progress" class="progress-bar"></div>
                </div>
                <button id="roll-button" style="display: none;">Roll Out Dough</button>
            </div>
    
            <!-- Stage 4: Rolling -->
            <div id="stage-rolling" class="stage">
                <h2>Step 4: Roll it Out</h2>
                <p>Roll the dough into a thin sheet.</p>
                <div class="visual">📏</div> <!-- Rolling pin emoji might not exist, using ruler -->
                <button id="start-rolling-button">Start Rolling</button>
                 <div class="progress-bar-container" style="display: none;">
                    <div id="rolling-progress" class="progress-bar"></div>
                </div>
                <button id="cut-button" style="display: none;">Cut into Shapes</button>
            </div>
    
            <!-- Stage 5: Cutting -->
            <div id="stage-cutting" class="stage">
                <h2>Step 5: Choose Your Shape</h2>
                <p>Select the type of pasta you want to make:</p>
                <div class="shape-options">
                    <div class="option shape" data-shape="spaghetti">🍝</div>
                    <div class="option shape" data-shape="penne">🖊️</div> <!-- Using pen emoji as proxy -->
                    <div class="option shape" data-shape="farfalle">🦋</div>
                    <div class="option shape" data-shape="ravioli">🥟</div> <!-- Using dumpling as proxy -->
                </div>
                <button id="finish-button" disabled>Finish Pasta!</button>
            </div>
    
            <!-- Stage 6: Finished -->
            <div id="stage-finished" class="stage">
                <h2>Congratulations!</h2>
                <p>You made delicious pasta!</p>
                <div id="final-pasta-display"></div>
                 <p>Enjoy your virtual meal!</p>
                <button id="play-again-button">Make More Pasta!</button>
            </div>
    
        </div>
    
        <script>
            // --- DOM Elements ---
            const stages = document.querySelectorAll('.stage');
            const gameContainer = document.getElementById('game-container');
    
            // Stage 1: Ingredients
            const ingredientOptions = document.querySelectorAll('#stage-ingredients .option');
            const mixButton = document.getElementById('mix-button');
            const selectedIngredientsCount = document.getElementById('selected-ingredients-count');
            let selectedIngredients = new Set();
    
            // Stage 2: Mixing
            const startMixingButton = document.getElementById('start-mixing-button');
            const mixingProgressBarContainer = document.querySelector('#stage-mixing .progress-bar-container');
            const mixingProgress = document.getElementById('mixing-progress');
            const kneadButton = document.getElementById('knead-button');
            const mixingVisual = document.querySelector('#stage-mixing .visual');
    
            // Stage 3: Kneading
            const kneadActionButton = document.getElementById('knead-action-button');
            const kneadingProgress = document.getElementById('kneading-progress');
            const rollButton = document.getElementById('roll-button');
            const kneadingVisual = document.getElementById('kneading-visual');
            let kneadCount = 0;
            const requiredKneads = 10;
    
            // Stage 4: Rolling
            const startRollingButton = document.getElementById('start-rolling-button');
            const rollingProgressBarContainer = document.querySelector('#stage-rolling .progress-bar-container');
            const rollingProgress = document.getElementById('rolling-progress');
            const cutButton = document.getElementById('cut-button');
            const rollingVisual = document.querySelector('#stage-rolling .visual');
    
            // Stage 5: Cutting
            const shapeOptions = document.querySelectorAll('#stage-cutting .option');
            const finishButton = document.getElementById('finish-button');
            let selectedShape = null;
    
            // Stage 6: Finished
            const finalPastaDisplay = document.getElementById('final-pasta-display');
            const playAgainButton = document.getElementById('play-again-button');
    
            // --- Game State ---
            let currentStage = 'ingredients';
    
            // --- Functions ---
            function showStage(stageId) {
                stages.forEach(stage => {
                    stage.classList.remove('active');
                });
                const nextStage = document.getElementById(`stage-${stageId}`);
                if (nextStage) {
                    nextStage.classList.add('active');
                    currentStage = stageId;
                     // Scroll to top on stage change for better mobile UX
                    gameContainer.scrollTop = 0;
                    window.scrollTo(0, 0);
                } else {
                    console.error("Stage not found:", stageId);
                }
            }
    
            function updateProgress(progressBar, percentage) {
                progressBar.style.width = `${percentage}%`;
            }
    
            function resetGame() {
                // Reset ingredients
                selectedIngredients.clear();
                ingredientOptions.forEach(opt => opt.classList.remove('selected'));
                selectedIngredientsCount.textContent = '0';
                mixButton.disabled = true;
    
                // Reset mixing
                mixingVisual.textContent = '🥣';
                mixingProgressBarContainer.style.display = 'none';
                updateProgress(mixingProgress, 0);
                startMixingButton.style.display = 'inline-block';
                kneadButton.style.display = 'none';
    
                // Reset kneading
                kneadCount = 0;
                kneadingVisual.textContent = '✊';
                kneadActionButton.textContent = `Knead (${kneadCount}/${requiredKneads})`;
                kneadActionButton.disabled = false;
                updateProgress(kneadingProgress, 0);
                rollButton.style.display = 'none';
    
    
                // Reset rolling
                rollingVisual.textContent = '📏';
                rollingProgressBarContainer.style.display = 'none';
                updateProgress(rollingProgress, 0);
                startRollingButton.style.display = 'inline-block';
                cutButton.style.display = 'none';
    
                // Reset cutting
                selectedShape = null;
                shapeOptions.forEach(opt => opt.classList.remove('selected'));
                finishButton.disabled = true;
    
                // Reset final display
                finalPastaDisplay.textContent = '';
    
                // Go to first stage
                showStage('ingredients');
            }
    
            // --- Event Listeners ---
    
            // Stage 1: Ingredients Logic
            ingredientOptions.forEach(option => {
                option.addEventListener('click', () => {
                    const ingredient = option.dataset.ingredient;
                    if (selectedIngredients.has(ingredient)) {
                        selectedIngredients.delete(ingredient);
                        option.classList.remove('selected');
                    } else {
                        selectedIngredients.add(ingredient);
                        option.classList.add('selected');
                    }
                    selectedIngredientsCount.textContent = selectedIngredients.size;
                    mixButton.disabled = selectedIngredients.size !== 3;
                });
            });
    
            mixButton.addEventListener('click', () => {
                showStage('mixing');
            });
    
            // Stage 2: Mixing Logic
            startMixingButton.addEventListener('click', () => {
                startMixingButton.style.display = 'none'; // Hide button
                mixingProgressBarContainer.style.display = 'block'; // Show progress bar
                mixingVisual.textContent = '🌀'; // Change visual
                let progress = 0;
                const interval = setInterval(() => {
                    progress += 20; // Simulate progress
                    updateProgress(mixingProgress, progress);
                    if (progress >= 100) {
                        clearInterval(interval);
                        mixingVisual.textContent = '🟡'; // Dough ball
                        kneadButton.style.display = 'inline-block'; // Show next button
                    }
                }, 400); // Adjust time for mixing duration
            });
    
            kneadButton.addEventListener('click', () => {
                showStage('kneading');
            });
    
            // Stage 3: Kneading Logic
            kneadActionButton.addEventListener('click', () => {
                kneadCount++;
                const progress = Math.min(100, (kneadCount / requiredKneads) * 100);
                updateProgress(kneadingProgress, progress);
                kneadActionButton.textContent = `Knead (${kneadCount}/${requiredKneads})`;
    
                // Simple visual feedback
                kneadingVisual.style.transform = `scale(${1 + kneadCount * 0.02})`;
                setTimeout(() => { kneadingVisual.style.transform = 'scale(1)';}, 100);
    
    
                if (kneadCount >= requiredKneads) {
                    kneadActionButton.disabled = true;
                    kneadingVisual.textContent = '🌟'; // Smooth dough
                    rollButton.style.display = 'inline-block';
                }
            });
    
            rollButton.addEventListener('click', () => {
                showStage('rolling');
            });
    
             // Stage 4: Rolling Logic
            startRollingButton.addEventListener('click', () => {
                startRollingButton.style.display = 'none';
                rollingProgressBarContainer.style.display = 'block';
                rollingVisual.textContent = ' S t r e t c h '; // Indicate rolling
                rollingVisual.style.fontSize = '2.5em'; // Make text fit
    
                let progress = 0;
                const interval = setInterval(() => {
                    progress += 25; // Simulate progress
                    updateProgress(rollingProgress, progress);
                    if (progress >= 100) {
                        clearInterval(interval);
                        rollingVisual.textContent = '📄'; // Flat sheet
                        rollingVisual.style.fontSize = '5em'; // Reset size
                        cutButton.style.display = 'inline-block';
                    }
                }, 500); // Adjust time for rolling duration
            });
    
             cutButton.addEventListener('click', () => {
                showStage('cutting');
            });
    
            // Stage 5: Cutting Logic
            shapeOptions.forEach(option => {
                option.addEventListener('click', () => {
                    // Deselect previous
                    shapeOptions.forEach(opt => opt.classList.remove('selected'));
                    // Select current
                    option.classList.add('selected');
                    selectedShape = option.dataset.shape;
                    finalPastaDisplay.textContent = option.textContent; // Set the final display emoji
                    finishButton.disabled = false;
                });
            });
    
            finishButton.addEventListener('click', () => {
                showStage('finished');
            });
    
            // Stage 6: Finished Logic
            playAgainButton.addEventListener('click', () => {
                resetGame();
            });
    
            // --- Initial Setup ---
            // (No specific init needed beyond showing the first stage, which is done by default)
            // Optional: Add a check for touch events early on if needed
            // document.body.addEventListener('touchstart', function () {}, {passive: true});
    
    
        </script>
    
    </body>
    </html>
    

    How to Use:

    1. Save: Copy all the code above and paste it into a plain text file. Save the file with an .html extension (e.g., pasta_game.html).
    2. Open: Open the saved HTML file in a web browser on your computer or mobile device. Mobile browsers work best for the intended experience.
    3. Play: Follow the on-screen instructions! Tap the ingredients, then the buttons for each step (Mix, Knead, Roll), choose a shape, and finish.

    Enjoy your simple pasta-making adventure!

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.