export default function ClosetPackingGame() { const [items, setItems] = useState([ { id: 1, name: "Shoe Box", width: 100, height: 50 }, { id: 2, name: "Shirt", width: 120, height: 60 }, { id: 3, name: "Pants", width: 150, height: 80 }, { id: 4, name: "Jacket", width: 180, height: 100 }, ]); const [placedItems, setPlacedItems] = useState([]); const [closetSize, setClosetSize] = useState({ width: 400, height: 500 }); const [gameOver, setGameOver] = useState(false); function placeItem(item) { if (!gameOver) { const newPlacedItems = [...placedItems, item]; const totalHeight = newPlacedItems.reduce((sum, i) => sum + i.height, 0); if (totalHeight > closetSize.height) { setGameOver(true); } else { setPlacedItems(newPlacedItems); } } } function restartGame() { setPlacedItems([]); setGameOver(false); } return (
Czy zmieścisz wszystko?
{placedItems.map((item, index) => (
{item.name}
))}
{gameOver ? (
Ups! Za dużo rzeczy, closet nie pomieści wszystkiego!
) : (
Wybierz przedmiot do umieszczenia:
{items.map((item) => (
placeItem(item)} > {item.name}
))}
)}
Restart
); }
top of page
718-552-6733
Why us?
click for more...
Read More
About us
Our creations
Materials
Solutions
Contact us!
More
Use tab to navigate through the menu items.
bottom of page