emoji TIC TAC TOE
Emoji Tic Tac Toe
Sure, here is a single HTML file implementation of a TIC TAC TOE game with emojis. I also added some jokes related to emojis:
```
<!DOCTYPE html>
<html>
<head>
<title>Emoji Tic Tac Toe</title>
<style>
body {
font-size: 50px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
font-family: 'Segoe UI Symbol', sans-serif;
}
.box {
border: 2px solid black;
width: 100px;
height: 100px;
display: flex;
align-items: center;
justify-content: center;
}
.row {
display: flex;
}
</style>
</head>
<body>
<div>
<div class="row">
<div class="box" id="00" onclick="play(this)"></div>
<div class="box" id="01" onclick="play(this)"></div>
<div class="box" id="02" onclick="play(this)"></div>
</div>
<div class="row">
<div class="box" id="10" onclick="play(this)"></div>
<div class="box" id="11" onclick="play(this)"></div>
<div class="box" id="12" onclick="play(this)"></div>
</div>
<div class="row">
<div class="box" id="20" onclick="play(this)"></div>
<div class="box" id="21" onclick="play(this)"></div>
<div class="box" id="22" onclick="play(this)"></div>
</div>
<div id="result"></div>
</div>
<script>
let currentPlayer = '๐พ';
let board = [
['','',''],
['','',''],
['','',''],
];
function play(box) {
if (box.innerHTML !== '') {
return;
}
box.innerHTML = currentPlayer;
let [i, j] = box.id.split('');
board[i][j] = currentPlayer;
if (checkWin(i, j)) {
document.getElementById('result').innerHTML = `${currentPlayer} wins ๐`;
disableClicks();
} else if (checkDraw()) {
document.getElementById('result').innerHTML = `Draw ๐`;
} else {
currentPlayer = currentPlayer === '๐พ' ? '๐ฝ' : '๐พ';
}
}
function checkWin(row, col) {
return checkRow(row) || checkCol(col) || checkDiagonal(row, col);
}
function checkRow(row) {
return board[row][0] !== '' && board[row][0] === board[row][1] && board[row][1] === board[row][2];
}
function checkCol(col) {
return board[0][col] !== '' && board[0][col] === board[1][col] && board[1][col] === board[2][col];
}
function checkDiagonal(row, col) {
if ((row === 0 && col === 0) || (row === 1 && col === 1) || (row === 2 && col === 2)) {
return board[0][0] !== '' && board[0][0] === board[1][1] && board[1][1] === board[2][2];
} else if ((row === 0 && col === 2) || (row === 1 && col === 1) || (row === 2 && col === 0)) {
return board[0][2] !== '' && board[0][2] === board[1][1] && board[1][1] === board[2][0];
} else {
return false;
}
}
function checkDraw() {
for (let i = 0; i < 3; i++) {
for (let j = 0; j < 3; j++) {
if (board[i][j] === '') {
return false;
}
}
}
return true;
}
function disableClicks() {
let boxes = document.querySelectorAll('.box');
for (let box of boxes) {
box.onclick = null;
}
}
</script>
</body>
</html>
```
Jokes:
- Why did the emoji go to school? To learn how to spell.
- What do you call an alligator in a vest? An investigator ๐๐ต๏ธโโ๏ธ
- How do you communicate with a fish? You drop it a line ๐ฃ๐