Stworzę dla Ciebie grę "Luffy's Treasure Hunt" - logiczną grę matematyczną inspirowaną One Piece z elementami 3D!
html
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Luffy's Treasure Hunt - Gra Matematyczna</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Comic Sans MS', cursive;
background: linear-gradient(135deg, #87CEEB 0%, #4682B4 100%);
min-height: 100vh;
overflow-x: hidden;
}
.game-container {
perspective: 1000px;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
padding: 20px;
}
.header {
text-align: center;
margin-bottom: 30px;
color: #fff;
text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}
.header h1 {
font-size: 3em;
margin-bottom: 10px;
color: #FFD700;
}
.score-board {
background: rgba(255,255,255,0.9);
padding: 15px 30px;
border-radius: 15px;
margin-bottom: 20px;
box-shadow: 0 5px 15px rgba(0,0,0,0.3);
font-size: 1.2em;
font-weight: bold;
}
.island {
width: 600px;
height: 400px;
background: linear-gradient(45deg, #90EE90, #32CD32);
border-radius: 50%;
position: relative;
transform-style: preserve-3d;
transform: rotateX(20deg) rotateY(0deg);
box-shadow: 0 20px 40px rgba(0,0,0,0.3);
margin-bottom: 30px;
}
.treasure-chest {
position: absolute;
width: 80px;
height: 60px;
background: linear-gradient(45deg, #8B4513, #A0522D);
border-radius: 10px;
cursor: pointer;
transform-style: preserve-3d;
transition: all 0.3s ease;
border: 3px solid #654321;
}
.treasure-chest:hover {
transform: scale(1.1) rotateY(10deg);
box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}
.treasure-chest::before {
content: '💎';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 1.5em;
}
.treasure-chest.opened {
background: linear-gradient(45deg, #FFD700, #FFA500);
animation: bounce 0.5s ease;
}
.treasure-chest.opened::before {
content: '✨';
}
@keyframes bounce {
0%, 100% { transform: scale(1.1) translateY(0); }
50% { transform: scale(1.2) translateY(-10px); }
}
.chest1 { top: 30%; left: 20%; }
.chest2 { top: 40%; left: 60%; }
.chest3 { top: 70%; left: 35%; }
.chest4 { top: 25%; left: 75%; }
.chest5 { top: 60%; left: 15%; }
.luffy {
position: absolute;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
font-size: 3em;
animation: float 2s ease-in-out infinite;
}
@keyframes float {
0%, 100% { transform: translateX(-50%) translateY(0); }
50% { transform: translateX(-50%) translateY(-10px); }
}
.math-popup {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) scale(0);
background: linear-gradient(135deg, #FF6B6B, #4ECDC4);
padding: 30px;
border-radius: 20px;
box-shadow: 0 20px 40px rgba(0,0,0,0.3);
text-align: center;
z-index: 1000;
transition: all 0.3s ease;
color: white;
min-width: 300px;
}
.math-popup.show {
transform: translate(-50%, -50%) scale(1);
}
.math-question {
font-size: 2em;
margin-bottom: 20px;
font-weight: bold;
}
.answer-input {
font-size: 1.5em;
padding: 10px;
border: none;
border-radius: 10px;
text-align: center;
margin: 10px;
width: 100px;
}
.submit-btn {
background: #FFD700;
color: #333;
border: none;
padding: 15px 30px;
font-size: 1.2em;
border-radius: 10px;
cursor: pointer;
font-weight: bold;
transition: all 0.3s ease;
}
.submit-btn:hover {
transform: scale(1.05);
box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}
.result-message {
margin-top: 15px;
font-size: 1.2em;
font-weight: bold;
}
.congratulations {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.8);
display: none;
justify-content: center;
align-items: center;
z-index: 2000;
}
.congrats-content {
background: linear-gradient(135deg, #FFD700, #FFA500);
padding: 50px;
border-radius: 20px;
text-align: center;
color: #333;
animation: celebrate 1s ease;
}
@keyframes celebrate {
0% { transform: scale(0.5) rotate(-180deg); }
100% { transform: scale(1) rotate(0deg); }
}
.restart-btn {
background: #4ECDC4;
color: white;
border: none;
padding: 15px 30px;
font-size: 1.2em;
border-radius: 10px;
cursor: pointer;
margin-top: 20px;
font-weight: bold;
}
</style>
</head>
<body>
<div class="game-container">
<div class="header">
<h1>🏴☠️ Luffy's Treasure Hunt 🏴☠️</h1>
<p>Pomóż Luffy'emu znaleźć skarby rozwiązując zadania matematyczne!</p>
</div>
<div class="score-board">
<span>Skarby znalezione: <span id="treasures-found">0</span>/5</span> |
<span>Punkty: <span id="score">0</span></span>
</div>
<div class="island">
<div class="treasure-chest chest1" data-chest="1"></div>
<div class="treasure-chest chest2" data-chest="2"></div>
<div class="treasure-chest chest3" data-chest="3"></div>
<div class="treasure-chest chest4" data-chest="4"></div>
<div class="treasure-chest chest5" data-chest="5"></div>
<div class="luffy">🏴☠️</div>
</div>
<div class="math-popup" id="math-popup">
<div class="math-question" id="math-question"></div>
<input type="number" class="answer-input" id="answer-input" placeholder="?">
<br>
<button class="submit-btn" onclick="checkAnswer()">Otwórz skrzynię!</button>
<div class="result-message" id="result-message"></div>
</div>
<div class="congratulations" id="congratulations">
<div class="congrats-content">
<h2>🎉 Gratulacje! 🎉</h2>
<p>Luffy znalazł wszystkie skarby!</p>
<p>Końcowy wynik: <span id="final-score"></span> punktów</p>
<button class="restart-btn" onclick="restartGame()">Zagraj ponownie</button>
</div>
</div>
</div>
<script>
let currentChest = null;
let treasuresFound = 0;
let score = 0;
let currentAnswer = 0;
const mathProblems = [
{ question: "15 + 27 = ?", answer: 42 },
{ question: "8 × 7 = ?", answer: 56 },
{ question: "100 - 34 = ?", answer: 66 },
{ question: "9 × 6 = ?", answer: 54 },
{ question: "45 ÷ 5 = ?", answer: 9 }
];
function openChest(chestElement, chestNumber) {
if (chestElement.classList.contains('opened')) return;
currentChest = chestElement;
const problem = mathProblems[chestNumber - 1];
currentAnswer = problem.answer;
document.getElementById('math-question').textContent = problem.question;
document.getElementById('answer-input').value = '';
document.getElementById('result-message').textContent = '';
document.getElementById('math-popup').classList.add('show');
document.getElementById('answer-input').focus();
}
function checkAnswer() {
const userAnswer = parseInt(document.getElementById('answer-input').value);
const resultMessage = document.getElementById('result-message');
if (userAnswer === currentAnswer) {
resultMessage.textContent = "🎉 Świetnie! Skarb znaleziony!";
resultMessage.style.color = '#90EE90';
currentChest.classList.add('opened');
treasuresFound++;
score += 100;
updateScore();
setTimeout(() => {
document.getElementById('math-popup').classList.remove('show');
if (treasuresFound === 5) {
showCongratulations();
}
}, 1500);
} else {
resultMessage.textContent = "❌ Spróbuj ponownie!";
resultMessage.style.color = '#FF6B6B';
document.getElementById('answer-input').value = '';
document.getElementById('answer-input').focus();
}
}
function updateScore() {
document.getElementById('treasures-found').textContent = treasuresFound;
document.getElementById('score').textContent = score;
}
function showCongratulations() {
document.getElementById('final-score').textContent = score;
document.getElementById('congratulations').style.display = 'flex';
}
function restartGame() {
treasuresFound = 0;
score = 0;
updateScore();
document.querySelectorAll('.treasure-chest').forEach(chest => {
chest.classList.remove('opened');
});
document.getElementById('congratulations').style.display = 'none';
document.getElementById('math-popup').classList.remove('show');
}
// Event listeners
document.querySelectorAll('.treasure-chest').forEach(chest => {
chest.addEventListener('click', () => {
const chestNumber = parseInt(chest.dataset.chest);
openChest(chest, chestNumber);
});
});
document.getElementById('answer-input').addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
checkAnswer();
}
});
// Zamknij popup klikając poza nim
document.getElementById('math-popup').addEventListener('click', (e) => {
if (e.target === e.currentTarget) {
document.getElementById('math-popup').classList.remove('show');
}
});
</script>
</body>
</html>
Gra automatycznie dostosowuje się do różnych rozmiarów ekranu i jest gotowa do gry od razu po otwarciu w przeglądarce!