Okay, here is a simple Pasta Maker game concept implemented in a single HTML file. This version focuses on the core stages: choosing ingredients, mixing, kneading, shaping, and a final result. It uses basic HTML, CSS for styling, and JavaScript for interactivity.
Features:
- Mobile-Friendly: Uses viewport settings and simple tap/click interactions.
- Stages: Ingredient Selection -> Mixing -> Kneading -> Shaping -> Final Dish.
- Visual Feedback: Simple changes in appearance to show progress.
- Single File: All HTML, CSS, and JavaScript are embedded.
How to Use:
- Copy the entire code block below.
- Paste it into a new text file.
- Save the file with an
.html extension (e.g., pasta_game.html).
- Open the saved
.html file in a web browser (Chrome, Firefox, Safari - works on desktop and mobile browsers).
<!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 Maker Game</title>
<style>
/* Basic Reset & Body Styling */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: 'Arial', sans-serif;
-webkit-tap-highlight-color: transparent; /* Disable tap highlight on mobile */
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
overflow: hidden; /* Prevent scrolling */
color: #333;
}
/* Game Container */
#game-container {
width: 95%;
max-width: 500px;
height: 90vh;
max-height: 700px;
background-color: #fff;
border-radius: 15px;
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
overflow: hidden; /* Clip content within rounded corners */
position: relative; /* For absolute positioning of stages */
}
/* Stage Styling */
.stage {
padding: 20px;
text-align: center;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between; /* Push button to bottom */
opacity: 0;
visibility: hidden;
transition: opacity 0.5s ease-in-out, visibility 0s linear 0.5s;
background-color: #fff; /* Ensure background covers other stages */
}
.stage.active {
opacity: 1;
visibility: visible;
transition: opacity 0.5s ease-in-out;
z-index: 10; /* Bring active stage to front */
}
/* Stage Content Styling */
.stage h2 {
margin-bottom: 20px;
color: #c62828; /* Pasta-red color */
}
.stage p {
margin-bottom: 15px;
color: #555;
flex-grow: 1; /* Allow instructions to take space */
overflow-y: auto; /* Scroll if instructions are long */
}
/* Interactive Elements */
.interactive-area {
flex-grow: 2; /* Give more space to interactive parts */
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-bottom: 20px;
gap: 15px; /* Space between items */
}
.ingredient, .shape-option, .action-item {
display: inline-block; /* Allow inline display with spacing */
padding: 10px 15px;
border: 2px solid #ddd;
border-radius: 8px;
cursor: pointer;
transition: background-color 0.3s, border-color 0.3s;
background-color: #f8f8f8;
user-select: none; /* Prevent text selection on tap */
font-size: 1em;
min-width: 80px; /* Ensure tap target size */
text-align: center;
}
.ingredient.added {
background-color: #dcedc8; /* Light green */
border-color: #a5d6a7;
}
.ingredient.disabled, .button:disabled {
opacity: 0.5;
cursor: not-allowed;
pointer-events: none; /* Disable clicks too */
}
.shape-option.selected {
background-color: #bbdefb; /* Light blue */
border-color: #90caf9;
font-weight: bold;
}
/* Visual Feedback Elements */
#mixing-bowl, #dough-area, #pasta-pot, #final-plate {
width: 150px;
height: 150px;
border: 3px dashed #ccc;
border-radius: 50%; /* Circle for bowl/dough */
margin: 10px auto;
display: flex;
justify-content: center;
align-items: center;
font-size: 0.9em;
color: #888;
position: relative; /* For positioning content inside */
background-color: #f0f0f0;
transition: background-color 0.5s, border-style 0.5s;
}
#final-plate {
border-radius: 10px; /* Plate shape */
width: 200px;
height: 130px;
border: 3px solid #aaa;
}
#dough-area.kneaded {
background-color: #fff59d; /* Yellowish dough */
border-style: solid;
border-color: #ffeb3b;
}
#pasta-pot.boiling::after {
content: '♨️'; /* Steam emoji */
position: absolute;
top: -10px;
font-size: 1.5em;
animation: steam 1.5s infinite linear;
}
@keyframes steam {
0% { transform: translateY(0); opacity: 0.6; }
50% { transform: translateY(-15px); opacity: 1; }
100% { transform: translateY(-30px); opacity: 0; }
}
/* Buttons */
.button {
padding: 12px 25px;
font-size: 1.1em;
color: #fff;
background-color: #ef5350; /* Red button */
border: none;
border-radius: 8px;
cursor: pointer;
transition: background-color 0.3s;
display: block; /* Make button take full width if needed */
width: 80%;
max-width: 250px;
margin: 10px auto 0; /* Center button */
}
.button:hover:not(:disabled) {
background-color: #e53935;
}
.button.secondary {
background-color: #78909c; /* Grey for restart */
}
.button.secondary:hover:not(:disabled) {
background-color: #607d8b;
}
</style>
</head>
<body>
<div id="game-container">
<!-- Stage 1: Ingredients -->
<div id="stage-ingredients" class="stage active">
<h2>Step 1: Choose Ingredients</h2>
<p>Tap the ingredients to add them to your bowl. You need Flour and Eggs!</p>
<div class="interactive-area">
<div id="mixing-bowl">Bowl</div>
<div>
<span class="ingredient" id="ingredient-flour" data-ingredient="flour">Flour 🍚</span>
<span class="ingredient" id="ingredient-eggs" data-ingredient="eggs">Eggs 🥚</span>
<span class="ingredient" id="ingredient-water" data-ingredient="water">Water 💧</span>
</div>
</div>
<button id="btn-mix" class="button" disabled>Mix Ingredients</button>
</div>
<!-- Stage 2: Mixing -->
<div id="stage-mixing" class="stage">
<h2>Step 2: Mix the Dough</h2>
<p>Tap the "Mix" button vigorously until the dough forms!</p>
<div class="interactive-area">
<div id="mixing-bowl-mix" style="font-size: 1.5em;">🥣</div>
<div id="mix-status">Ready to mix...</div>
</div>
<button id="btn-do-mix" class="button">Mix!</button>
<button id="btn-knead" class="button" style="display: none;">Knead Dough</button>
</div>
<!-- Stage 3: Kneading -->
<div id="stage-kneading" class="stage">
<h2>Step 3: Knead the Dough</h2>
<p>Tap the dough ball repeatedly to knead it until smooth.</p>
<div class="interactive-area">
<div id="dough-area" class="action-item">Dough Ball</div>
<div id="knead-status">Knead count: 0</div>
</div>
<button id="btn-shape" class="button" disabled>Shape Pasta</button>
</div>
<!-- Stage 4: Shaping -->
<div id="stage-shaping" class="stage">
<h2>Step 4: Shape Your Pasta</h2>
<p>Choose a pasta shape.</p>
<div class="interactive-area">
<span class="shape-option" data-shape="Fettuccine">Fettuccine</span>
<span class="shape-option" data-shape="Ravioli">Ravioli 🥟</span>
<span class="shape-option" data-shape="Spaghetti">Spaghetti 🍝</span>
<div id="shape-feedback" style="margin-top: 15px; font-weight: bold;"></div>
</div>
<button id="btn-cook" class="button" disabled>Cook Pasta</button>
</div>
<!-- Stage 5: Cooking (Simplified) -->
<div id="stage-cooking" class="stage">
<h2>Step 5: Cook the Pasta</h2>
<p>Tap the pot to drop the pasta in and cook it!</p>
<div class="interactive-area">
<div id="pasta-pot" class="action-item">Pot of Water 💧</div>
<div id="cooking-status">Ready to cook...</div>
</div>
<button id="btn-serve" class="button" disabled>Serve Pasta</button>
</div>
<!-- Stage 6: Final -->
<div id="stage-final" class="stage">
<h2>Bon Appétit!</h2>
<p>Your delicious homemade pasta is ready!</p>
<div class="interactive-area">
<div id="final-plate">
<span id="final-pasta-shape" style="font-size: 2em;"></span>
</div>
<div id="final-message">Enjoy your meal!</div>
</div>
<button id="btn-restart" class="button secondary">Make More Pasta!</button>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
// --- DOM Elements ---
const stages = document.querySelectorAll('.stage');
const gameContainer = document.getElementById('game-container');
// Stage 1: Ingredients
const ingredientButtons = document.querySelectorAll('.ingredient');
const mixingBowl = document.getElementById('mixing-bowl');
const btnMix = document.getElementById('btn-mix');
// Stage 2: Mixing
const btnDoMix = document.getElementById('btn-do-mix');
const mixStatus = document.getElementById('mix-status');
const mixingBowlMix = document.getElementById('mixing-bowl-mix');
const btnKnead = document.getElementById('btn-knead');
// Stage 3: Kneading
const doughArea = document.getElementById('dough-area');
const kneadStatus = document.getElementById('knead-status');
const btnShape = document.getElementById('btn-shape');
// Stage 4: Shaping
const shapeOptions = document.querySelectorAll('.shape-option');
const shapeFeedback = document.getElementById('shape-feedback');
const btnCook = document.getElementById('btn-cook');
// Stage 5: Cooking
const pastaPot = document.getElementById('pasta-pot');
const cookingStatus = document.getElementById('cooking-status');
const btnServe = document.getElementById('btn-serve');
// Stage 6: Final
const finalPlate = document.getElementById('final-plate');
const finalPastaShape = document.getElementById('final-pasta-shape');
const finalMessage = document.getElementById('final-message');
const btnRestart = document.getElementById('btn-restart');
// --- Game State ---
let currentStage = 'ingredients';
let ingredients = {
flour: false,
eggs: false,
water: false // Optional, not required to proceed in this simple version
};
let mixClicks = 0;
const mixClicksNeeded = 5; // How many clicks to "mix"
let kneadClicks = 0;
const kneadClicksNeeded = 8; // How many clicks to "knead"
let selectedShape = null;
let isCooked = false;
// --- 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;
console.log("Current Stage:", currentStage); // For debugging
} else {
console.error("Stage not found:", stageId);
}
}
function updateIngredientVisuals() {
let bowlContent = 'Bowl';
let addedCount = 0;
if (ingredients.flour) { bowlContent += ' +🍚'; addedCount++; }
if (ingredients.eggs) { bowlContent += ' +🥚'; addedCount++; }
if (ingredients.water) bowlContent += ' +💧';
mixingBowl.textContent = bowlContent;
// Enable mix button only if essential ingredients are added
btnMix.disabled = !(ingredients.flour && ingredients.eggs);
}
function resetGame() {
// Reset state variables
ingredients = { flour: false, eggs: false, water: false };
mixClicks = 0;
kneadClicks = 0;
selectedShape = null;
isCooked = false;
// Reset UI elements
ingredientButtons.forEach(btn => btn.classList.remove('added', 'disabled'));
mixingBowl.textContent = 'Bowl';
btnMix.disabled = true;
mixStatus.textContent = 'Ready to mix...';
mixingBowlMix.textContent = '🥣';
btnDoMix.style.display = 'inline-block'; // Show mix button again
btnKnead.style.display = 'none'; // Hide proceed button
doughArea.classList.remove('kneaded');
doughArea.textContent = 'Dough Ball';
kneadStatus.textContent = 'Knead count: 0';
btnShape.disabled = true;
shapeOptions.forEach(opt => opt.classList.remove('selected'));
shapeFeedback.textContent = '';
btnCook.disabled = true;
pastaPot.classList.remove('boiling');
pastaPot.innerHTML = 'Pot of Water 💧'; // Reset content
cookingStatus.textContent = 'Ready to cook...';
btnServe.disabled = true;
finalPastaShape.textContent = '';
finalMessage.textContent = 'Enjoy your meal!';
// Show the first stage
showStage('ingredients');
}
// --- Event Listeners ---
// Stage 1: Ingredients
ingredientButtons.forEach(button => {
button.addEventListener('click', () => {
const ingredientName = button.getAttribute('data-ingredient');
if (!ingredients[ingredientName]) {
ingredients[ingredientName] = true;
button.classList.add('added');
// Optional: disable after adding
// button.classList.add('disabled');
updateIngredientVisuals();
}
});
});
btnMix.addEventListener('click', () => {
showStage('mixing');
});
// Stage 2: Mixing
btnDoMix.addEventListener('click', () => {
mixClicks++;
mixStatus.textContent = `Mixing... ${mixClicks}/${mixClicksNeeded}`;
// Simple animation/visual feedback
mixingBowlMix.style.transform = `rotate(${mixClicks * 30}deg)`;
if (mixClicks >= mixClicksNeeded) {
mixStatus.textContent = 'Dough formed!';
mixingBowlMix.textContent = '🍪'; // Represent dough ball
btnDoMix.style.display = 'none'; // Hide mix button
btnKnead.style.display = 'inline-block'; // Show proceed button
}
});
btnKnead.addEventListener('click', () => {
showStage('kneading');
});
// Stage 3: Kneading
doughArea.addEventListener('click', () => {
if (kneadClicks < kneadClicksNeeded) {
kneadClicks++;
kneadStatus.textContent = `Knead count: ${kneadClicks}/${kneadClicksNeeded}`;
// Visual feedback: slight scale change
doughArea.style.transform = `scale(${1 + kneadClicks * 0.02})`;
setTimeout(() => doughArea.style.transform = 'scale(1)', 100); // Reset scale
if (kneadClicks >= kneadClicksNeeded) {
kneadStatus.textContent = 'Dough is smooth!';
doughArea.classList.add('kneaded');
doughArea.textContent = 'Smooth Dough';
btnShape.disabled = false;
}
}
});
btnShape.addEventListener('click', () => {
showStage('shaping');
});
// Stage 4: Shaping
shapeOptions.forEach(option => {
option.addEventListener('click', () => {
// Deselect others
shapeOptions.forEach(opt => opt.classList.remove('selected'));
// Select clicked one
option.classList.add('selected');
selectedShape = option.getAttribute('data-shape');
shapeFeedback.textContent = `Selected: ${selectedShape}`;
btnCook.disabled = false;
});
});
btnCook.addEventListener('click', () => {
if (selectedShape) {
showStage('cooking');
}
});
// Stage 5: Cooking
pastaPot.addEventListener('click', () => {
if (!isCooked) {
pastaPot.classList.add('boiling');
pastaPot.innerHTML = `${selectedShape === 'Ravioli' ? '🥟' : '🍝'} <br> Boiling...`; // Show pasta type
cookingStatus.textContent = 'Cooking... please wait!';
// Simulate cooking time
setTimeout(() => {
isCooked = true;
pastaPot.classList.remove('boiling');
pastaPot.innerHTML = `${selectedShape === 'Ravioli' ? '🥟' : '🍝'} <br> Cooked!`;
cookingStatus.textContent = 'Pasta is cooked!';
btnServe.disabled = false;
}, 3000); // 3 seconds cooking time
}
});
btnServe.addEventListener('click', () => {
if (isCooked) {
// Update final stage visuals
let pastaEmoji = '🍝'; // Default
if (selectedShape === 'Ravioli') pastaEmoji = '🥟';
if (selectedShape === 'Fettuccine') pastaEmoji = '🍜'; // Using noodle emoji as proxy
finalPastaShape.textContent = pastaEmoji;
finalMessage.textContent = `Enjoy your ${selectedShape}!`;
showStage('final');
}
});
// Stage 6: Final
btnRestart.addEventListener('click', resetGame);
// --- Initial Setup ---
resetGame(); // Initialize the game state and UI
});
</script>
</body>
</html>
Potential Improvements (More Complex):
- Better Graphics: Use images instead of text/emoji for ingredients, dough, pasta shapes, etc.
- More Animations: Add smoother transitions, mixing animations, rolling animations.
- More Choices: Different flour types, adding sauce/toppings.
- Sound Effects: Add sounds for tapping, mixing, boiling.
- Scoring/Timers: Introduce challenges or scoring based on speed or accuracy.
- Drag and Drop: Implement drag-and-drop for ingredients (more complex on mobile).
- Saving Progress: Use
localStorage to save game state (though less relevant for such a short game).