Sure! Below is a simple single HTML file for a mobile-friendly "Pasta Maker" game. This game allows users to select ingredients, mix them, and "make" pasta. It uses basic HTML, CSS, and JavaScript — no external libraries required.
You can copy and paste this into a .html file and open it in a mobile browser.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Pasta Maker Game</title>
<style>
body {
font-family: 'Arial', sans-serif;
background: #fff8e1;
margin: 0;
padding: 0;
text-align: center;
}
h1 {
background-color: #ffcc80;
margin: 0;
padding: 20px;
color: #5d4037;
}
.container {
padding: 20px;
}
.ingredients {
display: flex;
flex-wrap: wrap;
justify-content: center;
margin-bottom: 20px;
}
.ingredient {
background-color: #ffe0b2;
border: 2px solid #ffb74d;
border-radius: 10px;
padding: 10px 15px;
margin: 5px;
cursor: pointer;
transition: background-color 0.3s;
}
.ingredient.selected {
background-color: #ff9800;
color: white;
}
#mixButton, #resetButton {
background-color: #ff7043;
color: white;
border: none;
padding: 15px 30px;
font-size: 18px;
border-radius: 10px;
margin: 10px;
cursor: pointer;
}
#mixButton:hover, #resetButton:hover {
background-color: #f4511e;
}
#result {
margin-top: 20px;
font-size: 20px;
color: #4e342e;
}
#pastaImage {
margin-top: 20px;
max-width: 100%;
height: auto;
display: none;
}
</style>
</head>
<body>
<h1>🍝 Pasta Maker Game</h1>
<div class="container">
<h2>Select Ingredients:</h2>
<div class="ingredients" id="ingredientList">
<div class="ingredient" data-name="Flour">Flour</div>
<div class="ingredient" data-name="Eggs">Eggs</div>
<div class="ingredient" data-name="Water">Water</div>
<div class="ingredient" data-name="Salt">Salt</div>
<div class="ingredient" data-name="Olive Oil">Olive Oil</div>
<div class="ingredient" data-name="Tomato Sauce">Tomato Sauce</div>
<div class="ingredient" data-name="Cheese">Cheese</div>
<div class="ingredient" data-name="Basil">Basil</div>
</div>
<button id="mixButton">Mix & Make Pasta</button>
<button id="resetButton">Reset</button>
<div id="result"></div>
<img id="pastaImage" src="https://i.imgur.com/3ZQ3Z0P.png" alt="Pasta Ready!" />
</div>
<script>
const ingredients = document.querySelectorAll('.ingredient');
const mixButton = document.getElementById('mixButton');
const resetButton = document.getElementById('resetButton');
const result = document.getElementById('result');
const pastaImage = document.getElementById('pastaImage');
let selectedIngredients = [];
ingredients.forEach(item => {
item.addEventListener('click', () => {
const name = item.getAttribute('data-name');
if (selectedIngredients.includes(name)) {
selectedIngredients = selectedIngredients.filter(i => i !== name);
item.classList.remove('selected');
} else {
selectedIngredients.push(name);
item.classList.add('selected');
}
});
});
mixButton.addEventListener('click', () => {
if (selectedIngredients.includes('Flour') && selectedIngredients.includes('Eggs') && selectedIngredients.includes('Water')) {
result.innerHTML = `🎉 You made delicious pasta with: <strong>${selectedIngredients.join(', ')}</strong>!`;
pastaImage.style.display = 'block';
} else {
result.innerHTML = '❌ You need at least Flour, Eggs, and Water to make pasta!';
pastaImage.style.display = 'none';
}
});
resetButton.addEventListener('click', () => {
selectedIngredients = [];
ingredients.forEach(item => item.classList.remove('selected'));
result.innerHTML = '';
pastaImage.style.display = 'none';
});
</script>
</body>
</html>
✅ Features:
- Mobile responsive layout
- Tap to select/deselect ingredients
- Requires basic ingredients (Flour, Eggs, Water) to make pasta
- Shows a pasta image and success message
- Reset button to start over
📝 Note:
- The pasta image is loaded from Imgur. You can replace the
src of the image with your own hosted image if needed.
- This is a basic version. You can expand it with animations, sound effects, levels, or a progress bar for more fun!
Let me know if you want a version with sound, animations, or saving progress!