<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Aç Canavarım!</title>
<style>
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 15px;
font-family: Arial, sans-serif;
text-align: center;
background: linear-gradient(135deg,#b9f3ff,#f8d9ff);
color: #26334a;
}
.game {
max-width: 700px;
margin: auto;
background: white;
border-radius: 25px;
padding: 20px;
box-shadow: 0 8px 25px #7774;
}
h1 {
color: #7546b8;
font-size: 30px;
}
.info {
display: flex;
justify-content: space-between;
gap: 10px;
flex-wrap: wrap;
}
.pill {
background: #eee5ff;
padding: 10px 15px;
border-radius: 20px;
font-weight: bold;
}
.monster-area {
background: #f4f0ff;
border-radius: 25px;
padding: 15px;
margin: 20px 0;
}
.monster {
font-size: 110px;
display: inline-block;
}
.target {
font-size: 27px;
color: #7546b8;
font-weight: bold;
margin: 12px;
}
.objects {
display: grid;
grid-template-columns: repeat(5,1fr);
gap: 10px;
margin: 20px auto;
}
.item {
background: white;
border: 3px solid #ddd;
border-radius: 15px;
font-size: 35px;
padding: 12px 2px;
cursor: pointer;
}
.item.selected {
background: #fff0bd;
border-color: orange;
transform: scale(1.08);
}
.action {
border: none;
border-radius: 15px;
padding: 14px 18px;
margin: 5px;
background: #7546b8;
color: white;
font-size: 17px;
font-weight: bold;
cursor: pointer;
}
.secondary {
background: #e5e0ee;
color: #333;
}
.message {
font-size: 18px;
font-weight: bold;
min-height: 35px;
margin: 15px;
}
.happy {
animation: hop .5s ease 2;
}
.run {
animation: run 1.2s forwards;
}
@keyframes hop {
50% {
transform: translateY(-20px) rotate(10deg);
}
}
@keyframes run {
to {
transform: translateX(150%) rotate(30deg);
opacity: 0;
}
}
button:disabled {
opacity: .6;
}
@media(max-width:400px) {
.objects { gap: 5px; }
.item { font-size: 27px; }
}
</style>
</head>
<body>
<div class="game">
<h1>👾 Aç Canavarım!</h1>
<p>Canavarı doyurmak için doğru sayıyı bul!</p>
<div class="info">
<div class="pill">⭐ Puan: <span id="score">0</span></div>
<div class="pill">🎯 Soru: <span id="round">1</span></div>
</div>
<div class="monster-area">
<div id="monster" class="monster">👾</div>
<div id="prompt">
Merhaba! Ben aç bir canavarım!
</div>
<div id="target" class="target">
Hadi başlayalım!
</div>
</div>
<button class="action" id="start">
▶️ Oyuna Başla
</button>
<br>
<button class="action secondary" id="repeat">
🔊 Tekrar Dinle
</button>
<h3>🍎 Yiyecekleri seç!</h3>
<div class="objects" id="objects"></div>
<button class="action" id="feed">
👾 Canavarı Besle
</button>
<button class="action secondary" id="reset">
↻ Yeniden Başla
</button>
<div class="message" id="message">
Oyuna başlamak için butona bas!
</div>
<p>🌟 Her doğru cevap 10 puan!</p>
</div>
<script>
const foods = [
"🍎","🍌","🍓","🍐","🍊",
"🍇","🥕","🍉","🧁","🍪"
];
let target = 0;
let selected = [];
let score = 0;
let round = 1;
let locked = true;
let started = false;
const $ = id => document.getElementById(id);
// SESLİ ANLATIM
function speak(text) {
if (!("speechSynthesis" in window)) {
$("message").textContent =
"Tarayıcın ses özelliğini desteklemiyor.";
return;
}
window.speechSynthesis.cancel();
const voice = new SpeechSynthesisUtterance(text);
voice.lang = "tr-TR";
voice.rate = 0.85;
voice.pitch = 1.3;
voice.volume = 1;
window.speechSynthesis.speak(voice);
}
// SORUYU TEKRAR DİNLE
function repeatVoice() {
if (!started) {
speak("Önce oyuna başlayalım!");
return;
}
speak("Bana " + target +
" tane yiyecek verir misin?");
}
// YENİ SORU
function newRound() {
locked = false;
selected = [];
target = Math.floor(Math.random() * 10) + 1;
$("monster").className = "monster";
$("monster").textContent = "👾";
$("prompt").textContent =
"Acıktım! Bana yardım eder misin?";
$("target").textContent =
target + " tane istiyorum!";
$("message").textContent =
"Yiyecekleri say ve seç!";
$("round").textContent = round;
render();
speak("Bana " + target +
" tane yiyecek verir misin?");
}
// NESNELERİ OLUŞTUR
function render() {
const area = $("objects");
area.innerHTML = "";
foods.forEach((food,i) => {
const b = document.createElement("button");
b.className = "item" +
(selected.includes(i) ? " selected" : "");
b.textContent = food;
b.disabled = locked;
b.onclick = () => {
if (locked) return;
if (selected.includes(i)) {
selected = selected.filter(x => x !== i);
} else {
selected.push(i);
}
render();
$("message").textContent =
"Seçtiğin yiyecek sayısı: " + selected.length;
};
area.appendChild(b);
});
}
// CANAVARI BESLE
function feed() {
if (!started || locked) return;
if (selected.length === target) {
locked = true;
score += 10;
$("score").textContent = score;
$("message").textContent =
"Harikasın! Doğru saydın! 🎉 +10 puan";
$("prompt").textContent =
"Çok teşekkür ederim!";
$("target").textContent =
"Başardın! ⭐";
$("monster").textContent = "🥳";
$("monster").className = "monster happy";
speak("Harikasın! Çok güzel saydın! Teşekkür ederim!");
setTimeout(() => {
$("monster").className = "monster run";
$("prompt").textContent =
"Canavar kaçtı! Yeni görev geliyor!";
setTimeout(() => {
round++;
newRound();
},1200);
},1500);
} else {
$("message").textContent =
"Bir daha saymayı deneyelim! 😊";
$("monster").textContent = "🤔";
speak("Bir daha saymayı deneyelim!");
}
}
// OYUNU BAŞLAT
function startGame() {
started = true;
$("start").disabled = true;
$("start").textContent = "🎮 Oyun Başladı";
speak("Merhaba! Ben aç bir canavarım. Hadi oynayalım!");
setTimeout(() => {
newRound();
},1800);
}
// YENİDEN BAŞLAT
function restart() {
window.speechSynthesis.cancel();
score = 0;
round = 1;
started = false;
locked = true;
selected = [];
$("score").textContent = 0;
$("round").textContent = 1;
$("monster").textContent = "👾";
$("monster").className = "monster";
$("prompt").textContent =
"Merhaba! Ben aç bir canavarım!";
$("target").textContent = "Hadi başlayalım!";
$("message").textContent =
"Oyuna başlamak için butona bas!";
$("start").disabled = false;
$("start").textContent = "▶️ Oyuna Başla";
render();
}
// BUTONLAR
$("start").onclick = startGame;
$("repeat").onclick = repeatVoice;
$("feed").onclick = feed;
$("reset").onclick = restart;
render();
</script>
</body>
</html>