<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sayı Avcısı</title>
<style>
body {
font-family: Arial, sans-serif;
background: linear-gradient(135deg,#ffe6f0,#d9f3ff);
text-align: center;
margin: 0;
padding: 20px;
color: #444;
}
.container {
max-width: 600px;
margin: auto;
background: white;
padding: 25px;
border-radius: 25px;
box-shadow: 0 5px 20px #9995;
}
h1 { color: #ff6594; font-size: 34px; }
p { font-size: 21px; font-weight: bold; }
.objects {
min-height: 150px;
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
gap: 10px;
margin: 20px 0;
}
.objects span { font-size: 45px; }
.options {
display: flex;
justify-content: center;
gap: 15px;
}
button {
border: none;
border-radius: 18px;
padding: 18px 28px;
font-size: 27px;
font-weight: bold;
background: #ffe18b;
color: #654b00;
cursor: pointer;
}
button:active { transform: scale(.95); }
#message {
font-size: 23px;
font-weight: bold;
min-height: 35px;
margin: 20px;
}
#next {
display: none;
background: #80dcb5;
color: #174d39;
font-size: 20px;
}
#restart {
background: #d9e5ff;
font-size: 17px;
margin-top: 15px;
}
</style>
</head>
<body>
<div class="container">
<h1>🎈 Sayı Avcısı 🎈</h1>
<p>Nesneleri say ve doğru sayıyı bul!</p>
<p id="question">Soru: 1 / 10</p>
<p id="score">⭐ Puan: 0</p>
<div class="objects" id="objects"></div>
<p>Kaç tane nesne var?</p>
<div class="options" id="options"></div>
<div id="message">Haydi başlayalım! 😊</div>
<button id="next" onclick="nextQuestion()">
Sonraki soru ➜
</button>
<br>
<button id="restart" onclick="startGame()">
🔄 Yeniden başla
</button>
</div>
<script>
const questions = [
{emoji:"🎈", count:7},
{emoji:"🍎", count:4},
{emoji:"⭐", count:9},
{emoji:"🐠", count:3},
{emoji:"🦋", count:6},
{emoji:"🍓", count:5},
{emoji:"🚗", count:8},
{emoji:"🌼", count:2},
{emoji:"⚽", count:10},
{emoji:"🐞", count:1}
];
let current = 0;
let score = 0;
let answered = false;
let gameQuestions = [];
function shuffle(array) {
return [...array].sort(() => Math.random() - 0.5);
}
function startGame() {
current = 0;
score = 0;
gameQuestions = shuffle(questions);
document.getElementById("score").innerText = "⭐ Puan: 0";
showQuestion();
}
function showQuestion() {
answered = false;
const q = gameQuestions[current];
document.getElementById("question").innerText =
`Soru: ${current+1} / 10`;
document.getElementById("objects").innerHTML =
Array(q.count).fill(`<span>${q.emoji}</span>`).join("");
let choices = shuffle([
q.count,
...shuffle(
Array.from({length:10}, (_,i)=>i+1)
.filter(n=>n!==q.count)
).slice(0,2)
]);
document.getElementById("options").innerHTML = "";
choices.forEach(number => {
let btn = document.createElement("button");
btn.innerText = number;
btn.onclick = () => checkAnswer(number, btn);
document.getElementById("options").appendChild(btn);
});
document.getElementById("message").innerText =
"Sence doğru cevap hangisi? 🤔";
document.getElementById("next").style.display = "none";
}
function checkAnswer(number, button) {
if(answered) return;
answered = true;
const correct = gameQuestions[current].count;
document.querySelectorAll("#options button").forEach(btn => {
btn.disabled = true;
});
if(number === correct) {
score += 10;
document.getElementById("message").innerText =
"🎉 Harikasın! Doğru cevap!";
button.style.background = "#91e6b5";
} else {
document.getElementById("message").innerText =
`😊 Tekrar sayabilirsin! Doğru cevap: ${correct}`;
button.style.background = "#ffb5b5";
}
document.getElementById("score").innerText =
"⭐ Puan: " + score;
document.getElementById("next").style.display = "inline-block";
document.getElementById("next").innerText =
current === 9 ? "Oyunu bitir 🏆" : "Sonraki soru ➜";
}
function nextQuestion() {
if(current < 9) {
current++;
showQuestion();
} else {
document.getElementById("objects").innerHTML = "🏆🎉";
document.getElementById("options").innerHTML = "";
document.getElementById("question").innerText =
"Oyun tamamlandı!";
document.getElementById("message").innerText =
`Tebrikler! ${score} puan kazandın!`;
document.getElementById("next").style.display = "none";
}
}
startGame();
</script>
</body>
</html>