-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sadhika tadinada PR 3 #2826
Open
sadhikatadinada
wants to merge
1
commit into
zero-to-mastery:master
Choose a base branch
from
sadhikatadinada:sadhikat-pr-3
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
sadhika tadinada PR 3 #2826
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Tic Tac Toe</title> | ||
<link rel="stylesheet" href="styles.css"> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>Tic Tac Toe</h1> | ||
<div class="grid" id="grid"> | ||
<div class="cell" data-index="0"></div> | ||
<div class="cell" data-index="1"></div> | ||
<div class="cell" data-index="2"></div> | ||
<div class="cell" data-index="3"></div> | ||
<div class="cell" data-index="4"></div> | ||
<div class="cell" data-index="5"></div> | ||
<div class="cell" data-index="6"></div> | ||
<div class="cell" data-index="7"></div> | ||
<div class="cell" data-index="8"></div> | ||
</div> | ||
<button class="reset-btn" onclick="resetGame()">Reset Game</button> | ||
</div> | ||
|
||
<script> | ||
const cells = document.querySelectorAll('.cell'); | ||
let currentPlayer = 'X'; | ||
let board = ['', '', '', '', '', '', '', '', '']; | ||
|
||
cells.forEach(cell => { | ||
cell.addEventListener('click', () => { | ||
const index = cell.getAttribute('data-index'); | ||
|
||
if (board[index] === '' && !checkWinner()) { | ||
board[index] = currentPlayer; | ||
cell.classList.add(currentPlayer.toLowerCase()); | ||
cell.textContent = currentPlayer; | ||
currentPlayer = currentPlayer === 'X' ? 'O' : 'X'; | ||
} | ||
|
||
if (checkWinner()) { | ||
setTimeout(() => alert(`${currentPlayer === 'X' ? 'O' : 'X'} wins!`), 100); | ||
} | ||
}); | ||
}); | ||
|
||
function checkWinner() { | ||
const winningCombinations = [ | ||
[0, 1, 2], | ||
[3, 4, 5], | ||
[6, 7, 8], | ||
[0, 3, 6], | ||
[1, 4, 7], | ||
[2, 5, 8], | ||
[0, 4, 8], | ||
[2, 4, 6], | ||
]; | ||
|
||
return winningCombinations.some(combination => { | ||
const [a, b, c] = combination; | ||
return board[a] && board[a] === board[b] && board[a] === board[c]; | ||
}); | ||
} | ||
|
||
function resetGame() { | ||
board = ['', '', '', '', '', '', '', '', '']; | ||
currentPlayer = 'X'; | ||
cells.forEach(cell => { | ||
cell.textContent = ''; | ||
cell.classList.remove('x', 'o'); | ||
}); | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"artName": "Tic Tac Toe", | ||
"githubHandle": "sadhikatadinada" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
} | ||
|
||
body { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
background-color: #111; /* Dark background */ | ||
font-family: 'Arial', sans-serif; | ||
} | ||
|
||
.container { | ||
text-align: center; | ||
} | ||
|
||
h1 { | ||
color: #fff; | ||
margin-bottom: 20px; | ||
} | ||
|
||
.grid { | ||
display: grid; | ||
grid-template-columns: repeat(3, 100px); | ||
grid-template-rows: repeat(3, 100px); | ||
gap: 10px; | ||
} | ||
|
||
.cell { | ||
width: 100px; | ||
height: 100px; | ||
background-color: #222; /* Dark cell background */ | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
font-size: 3rem; | ||
color: #fff; | ||
cursor: pointer; | ||
transition: background-color 0.3s ease; | ||
position: relative; | ||
} | ||
|
||
.cell:hover { | ||
background-color: #333; /* Slightly lighter on hover */ | ||
} | ||
|
||
.cell.x { | ||
color: #ff4d4d; /* Neon red */ | ||
animation: neon-x 0.5s forwards; /* X animation */ | ||
} | ||
|
||
.cell.o { | ||
color: #4dff4d; /* Neon green */ | ||
animation: neon-o 0.5s forwards; /* O animation */ | ||
} | ||
|
||
@keyframes neon-x { | ||
0% { | ||
text-shadow: 0 0 5px #ff4d4d, 0 0 10px #ff4d4d, 0 0 15px #ff4d4d; | ||
transform: scale(1); | ||
} | ||
50% { | ||
transform: scale(1.1); | ||
} | ||
100% { | ||
transform: scale(1); | ||
} | ||
} | ||
|
||
@keyframes neon-o { | ||
0% { | ||
text-shadow: 0 0 5px #4dff4d, 0 0 10px #4dff4d, 0 0 15px #4dff4d; | ||
transform: scale(1); | ||
} | ||
50% { | ||
transform: scale(1.1); | ||
} | ||
100% { | ||
transform: scale(1); | ||
} | ||
} | ||
|
||
.reset-btn { | ||
margin-top: 20px; | ||
padding: 10px 20px; | ||
font-size: 1rem; | ||
background-color: #ffcc00; | ||
border: none; | ||
cursor: pointer; | ||
} | ||
|
||
.reset-btn:hover { | ||
background-color: #ffd700; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JS Not accepted in contribution
As the README.md states - we do not accept contribution using JS
The contribution should only be about an animation / creative animation without any logic or use of third part library to handle css
Observing what you have here:
What you could do is using CSS to animate all cells to show a tic tac toe round.
Using css timers to delay cells if needed.
Either close this PR / either adjust this PR so it does not use ANY JS