BALKOD
Anasayfa
Dersler
Etkinlikler
Oyunlar
İletişim
Demo Ders Al
Giriş
Oyun Kütüphanesi
Eğlenerek öğrenmek için seçtiğimiz eğitici oyunlar.
<!DOCTYPE html> <html lang="tr"> <head> <meta charset="UTF-8"> <style> body { font-family: 'Segoe UI', sans-serif; background: #2c3e50; color: white; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; margin: 0; } h2 { margin-bottom: 20px; color: #ecf0f1; } .board { display: grid; grid-template-columns: repeat(3, 100px); gap: 10px; } .cell { width: 100px; height: 100px; background: #34495e; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 3rem; font-weight: bold; cursor: pointer; transition: 0.3s; } .cell:hover { background: #465f75; } .cell.x { color: #e74c3c; } /* Kırmızı X */ .cell.o { color: #3498db; } /* Mavi O */ .status { margin-top: 20px; font-size: 1.5rem; height: 30px; } .btn-reset { margin-top: 20px; padding: 10px 20px; background: #27ae60; color: white; border: none; border-radius: 5px; cursor: pointer; font-size: 1rem; transition: 0.3s; } .btn-reset:hover { background: #2ecc71; } </style> </head> <body> <h2>Tic-Tac-Toe</h2> <div class="board" id="board"> <div class="cell" onclick="makeMove(0)"></div> <div class="cell" onclick="makeMove(1)"></div> <div class="cell" onclick="makeMove(2)"></div> <div class="cell" onclick="makeMove(3)"></div> <div class="cell" onclick="makeMove(4)"></div> <div class="cell" onclick="makeMove(5)"></div> <div class="cell" onclick="makeMove(6)"></div> <div class="cell" onclick="makeMove(7)"></div> <div class="cell" onclick="makeMove(8)"></div> </div> <div class="status" id="status">Sıra: X</div> <button class="btn-reset" onclick="resetGame()">Yeniden Başlat</button> <script> let board = ['', '', '', '', '', '', '', '', '']; let currentPlayer = 'X'; let gameActive = true; const statusDisplay = document.getElementById('status'); function makeMove(index) { if (board[index] === '' && gameActive) { board[index] = currentPlayer; document.getElementsByClassName('cell')[index].innerText = currentPlayer; document.getElementsByClassName('cell')[index].classList.add(currentPlayer.toLowerCase()); checkResult(); if (gameActive) { currentPlayer = currentPlayer === 'X' ? 'O' : 'X'; statusDisplay.innerText = "Sıra: " + currentPlayer; } } } function checkResult() { const winConditions = [ [0, 1, 2], [3, 4, 5], [6, 7, 8], // Yatay [0, 3, 6], [1, 4, 7], [2, 5, 8], // Dikey [0, 4, 8], [2, 4, 6] // Çapraz ]; let roundWon = false; for (let i = 0; i < winConditions.length; i++) { const [a, b, c] = winConditions[i]; if (board[a] && board[a] === board[b] && board[a] === board[c]) { roundWon = true; break; } } if (roundWon) { statusDisplay.innerText = "Kazanan: " + currentPlayer + " 🎉"; gameActive = false; return; } if (!board.includes('')) { statusDisplay.innerText = "Berabere! 🤝"; gameActive = false; return; } } function resetGame() { board = ['', '', '', '', '', '', '', '', '']; gameActive = true; currentPlayer = 'X'; statusDisplay.innerText = "Sıra: X"; const cells = document.getElementsByClassName('cell'); for (let i = 0; i < cells.length; i++) { cells[i].innerText = ''; cells[i].classList.remove('x', 'o'); } } </script> </body> </html>
Tic-Tac-Toe (XOX)
ŞİMDİ OYNA
Oyun
KAPAT