Spaces:
Running
Running
Download index.html from sergiomcfly/anycoder-e354dbc6: direct link, hf CLI and curl.
- Browser
- Download file 15.4 kB
-
https://huggingface.co/spaces/sergiomcfly/anycoder-e354dbc6/resolve/main/index.html
- Command line
-
hf download hf://spaces/sergiomcfly/anycoder-e354dbc6/index.html
-
curl -L -o index.html https://huggingface.co/spaces/sergiomcfly/anycoder-e354dbc6/resolve/main/index.html
15.4 kB
| <html lang="pt-BR"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Jogo da Velha Neon | Ultimate UI</title> | |
| <!-- Importing FontAwesome for Icons --> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| :root { | |
| --bg-color: #0f172a; | |
| --card-bg: rgba(30, 41, 59, 0.7); | |
| --text-color: #f8fafc; | |
| --accent-x: #00e5ff; /* Cyan Neon */ | |
| --accent-o: #ff007f; /* Magenta Neon */ | |
| --grid-gap: 15px; | |
| --cell-size: 100px; | |
| --glass-border: 1px solid rgba(255, 255, 255, 0.1); | |
| --shadow-glow: 0 0 20px rgba(0, 0, 0, 0.5); | |
| } | |
| * { | |
| margin: 0; | |
| padding: 0; | |
| box-sizing: border-box; | |
| font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | |
| } | |
| body { | |
| background-color: var(--bg-color); | |
| background-image: | |
| radial-gradient(circle at 10% 20%, rgba(0, 229, 255, 0.1) 0%, transparent 20%), | |
| radial-gradient(circle at 90% 80%, rgba(255, 0, 127, 0.1) 0%, transparent 20%); | |
| color: var(--text-color); | |
| height: 100vh; | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| overflow: hidden; | |
| } | |
| /* --- Header & Attribution --- */ | |
| .header-container { | |
| position: absolute; | |
| top: 20px; | |
| text-align: center; | |
| z-index: 10; | |
| } | |
| .anycoder-link { | |
| text-decoration: none; | |
| color: rgba(255, 255, 255, 0.6); | |
| font-size: 0.9rem; | |
| transition: color 0.3s ease; | |
| border: 1px solid rgba(255,255,255,0.2); | |
| padding: 5px 15px; | |
| border-radius: 20px; | |
| background: rgba(0,0,0,0.3); | |
| backdrop-filter: blur(5px); | |
| } | |
| .anycoder-link:hover { | |
| color: #fff; | |
| border-color: #fff; | |
| background: rgba(255,255,255,0.1); | |
| } | |
| /* --- Main Game Card --- */ | |
| .game-card { | |
| background: var(--card-bg); | |
| backdrop-filter: blur(16px); | |
| -webkit-backdrop-filter: blur(16px); | |
| border: var(--glass-border); | |
| border-radius: 24px; | |
| padding: 2rem; | |
| box-shadow: var(--shadow-glow); | |
| display: flex; | |
| flex-direction: column; | |
| align-items: center; | |
| max-width: 90%; | |
| animation: float 6s ease-in-out infinite; | |
| } | |
| @keyframes float { | |
| 0% { transform: translateY(0px); } | |
| 50% { transform: translateY(-10px); } | |
| 100% { transform: translateY(0px); } | |
| } | |
| h1 { | |
| font-weight: 800; | |
| margin-bottom: 1.5rem; | |
| letter-spacing: 2px; | |
| text-transform: uppercase; | |
| background: linear-gradient(90deg, var(--accent-x), #fff, var(--accent-o)); | |
| -webkit-background-clip: text; | |
| -webkit-text-fill-color: transparent; | |
| font-size: 2rem; | |
| } | |
| /* --- Scoreboard --- */ | |
| .scoreboard { | |
| display: flex; | |
| justify-content: space-between; | |
| width: 100%; | |
| margin-bottom: 20px; | |
| padding: 0 10px; | |
| } | |
| .player-score { | |
| display: flex; | |
| flex-direction: column; | |
| align-items: center; | |
| padding: 10px 20px; | |
| border-radius: 12px; | |
| background: rgba(255, 255, 255, 0.05); | |
| transition: all 0.3s ease; | |
| min-width: 100px; | |
| } | |
| .player-score.active { | |
| background: rgba(255, 255, 255, 0.15); | |
| transform: scale(1.05); | |
| box-shadow: 0 4px 15px rgba(0,0,0,0.2); | |
| } | |
| .player-score.x-score { border-bottom: 3px solid var(--accent-x); } | |
| .player-score.o-score { border-bottom: 3px solid var(--accent-o); } | |
| .score-val { | |
| font-size: 1.5rem; | |
| font-weight: bold; | |
| margin-top: 5px; | |
| } | |
| .status-text { | |
| margin-bottom: 20px; | |
| font-size: 1.1rem; | |
| color: #94a3b8; | |
| height: 24px; /* Prevent layout shift */ | |
| } | |
| /* --- The Grid --- */ | |
| .board { | |
| display: grid; | |
| grid-template-columns: repeat(3, 1fr); | |
| gap: var(--grid-gap); | |
| margin-bottom: 20px; | |
| } | |
| .cell { | |
| width: var(--cell-size); | |
| height: var(--cell-size); | |
| background: rgba(255, 255, 255, 0.03); | |
| border-radius: 16px; | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| font-size: 3rem; | |
| cursor: pointer; | |
| transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); | |
| border: 1px solid transparent; | |
| box-shadow: inset 0 0 10px rgba(0,0,0,0.2); | |
| position: relative; | |
| overflow: hidden; | |
| } | |
| .cell:hover:not(.taken) { | |
| background: rgba(255, 255, 255, 0.08); | |
| transform: translateY(-2px); | |
| border-color: rgba(255, 255, 255, 0.1); | |
| } | |
| .cell.taken { | |
| cursor: default; | |
| } | |
| /* Marks Styling */ | |
| .cell.x { | |
| color: var(--accent-x); | |
| text-shadow: 0 0 15px var(--accent-x); | |
| } | |
| .cell.o { | |
| color: var(--accent-o); | |
| text-shadow: 0 0 15px var(--accent-o); | |
| } | |
| /* Animation for placing marks */ | |
| .pop-in { | |
| animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; | |
| } | |
| @keyframes popIn { | |
| 0% { transform: scale(0); opacity: 0; } | |
| 100% { transform: scale(1); opacity: 1; } | |
| } | |
| /* Winning Cell Highlight */ | |
| .cell.win { | |
| background: rgba(255, 255, 255, 0.15); | |
| animation: pulseWin 1.5s infinite; | |
| } | |
| @keyframes pulseWin { | |
| 0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4); } | |
| 70% { box-shadow: 0 0 0 10px rgba(255, 255, 255, 0); } | |
| 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); } | |
| } | |
| /* --- Controls --- */ | |
| .restart-btn { | |
| background: linear-gradient(135deg, #6366f1, #a855f7); | |
| border: none; | |
| padding: 12px 30px; | |
| border-radius: 50px; | |
| color: white; | |
| font-weight: bold; | |
| font-size: 1rem; | |
| cursor: pointer; | |
| transition: transform 0.2s, box-shadow 0.2s; | |
| box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4); | |
| display: flex; | |
| align-items: center; | |
| gap: 10px; | |
| } | |
| .restart-btn:hover { | |
| transform: translateY(-2px); | |
| box-shadow: 0 6px 20px rgba(168, 85, 247, 0.6); | |
| } | |
| .restart-btn:active { | |
| transform: translateY(1px); | |
| } | |
| /* --- Responsive Design --- */ | |
| @media (max-width: 450px) { | |
| :root { | |
| --cell-size: 80px; | |
| --grid-gap: 10px; | |
| } | |
| h1 { font-size: 1.5rem; } | |
| .game-card { padding: 1.5rem; } | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <!-- Header with Attribution --> | |
| <div class="header-container"> | |
| <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="anycoder-link"> | |
| <i class="fa-solid fa-code"></i> Built with anycoder | |
| </a> | |
| </div> | |
| <!-- Main Game Interface --> | |
| <div class="game-card"> | |
| <h1>Jogo da Velha</h1> | |
| <div class="scoreboard"> | |
| <div class="player-score x-score active" id="score-box-x"> | |
| <span>Jogador X</span> | |
| <span class="score-val" id="score-x">0</span> | |
| </div> | |
| <div class="player-score o-score" id="score-box-o"> | |
| <span>Jogador O</span> | |
| <span class="score-val" id="score-o">0</span> | |
| </div> | |
| </div> | |
| <div class="status-text" id="status-text">Vez de: <span style="color: var(--accent-x)">X</span></div> | |
| <div class="board" id="board"> | |
| <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="restart-btn" onclick="restartGame()"> | |
| <i class="fa-solid fa-rotate-right"></i> Reiniciar Jogo | |
| </button> | |
| </div> | |
| <script> | |
| /* --- Game State --- */ | |
| const X_CLASS = 'x'; | |
| const O_CLASS = 'o'; | |
| const WINNING_COMBINATIONS = [ | |
| [0, 1, 2], [3, 4, 5], [6, 7, 8], // Rows | |
| [0, 3, 6], [1, 4, 7], [2, 5, 8], // Columns | |
| [0, 4, 8], [2, 4, 6] // Diagonals | |
| ]; | |
| const cellElements = document.querySelectorAll('.cell'); | |
| const board = document.getElementById('board'); | |
| const statusText = document.getElementById('status-text'); | |
| const scoreXEl = document.getElementById('score-x'); | |
| const scoreOEl = document.getElementById('score-o'); | |
| const scoreBoxX = document.getElementById('score-box-x'); | |
| const scoreBoxO = document.getElementById('score-box-o'); | |
| let oTurn; | |
| let gameActive = true; | |
| let scores = { x: 0, o: 0 }; | |
| /* --- Initialization --- */ | |
| startGame(); | |
| function startGame() { | |
| oTurn = false; | |
| gameActive = true; | |
| cellElements.forEach(cell => { | |
| cell.classList.remove(X_CLASS); | |
| cell.classList.remove(O_CLASS); | |
| cell.classList.remove('taken'); | |
| cell.classList.remove('win'); | |
| cell.innerHTML = ''; | |
| cell.removeEventListener('click', handleClick); | |
| cell.addEventListener('click', handleClick, { once: true }); | |
| }); | |
| updateStatusUI(); | |
| updateScoreUI(); | |
| } | |
| /* --- Core Logic --- */ | |
| function handleClick(e) { | |
| if (!gameActive) return; | |
| const cell = e.target; | |
| const currentClass = oTurn ? O_CLASS : X_CLASS; | |
| placeMark(cell, currentClass); | |
| if (checkWin(currentClass)) { | |
| endGame(false); | |
| } else if (isDraw()) { | |
| endGame(true); | |
| } else { | |
| swapTurns(); | |
| updateStatusUI(); | |
| } | |
| } | |
| function placeMark(cell, currentClass) { | |
| cell.classList.add(currentClass); | |
| cell.classList.add('taken'); | |
| // Add Icon based on class | |
| const icon = currentClass === X_CLASS | |
| ? '<i class="fa-solid fa-xmark pop-in"></i>' | |
| : '<i class="fa-solid fa-circle pop-in"></i>'; | |
| cell.innerHTML = icon; | |
| } | |
| function swapTurns() { | |
| oTurn = !oTurn; | |
| } | |
| function updateStatusUI() { | |
| const player = oTurn ? 'O' : 'X'; | |
| const color = oTurn ? 'var(--accent-o)' : 'var(--accent-x)'; | |
| statusText.innerHTML = `Vez de: <span style="color: ${color}; font-weight:bold">${player}</span>`; | |
| // Highlight active player score box | |
| if (oTurn) { | |
| scoreBoxX.classList.remove('active'); | |
| scoreBoxO.classList.add('active'); | |
| } else { | |
| scoreBoxO.classList.remove('active'); | |
| scoreBoxX.classList.add('active'); | |
| } | |
| } | |
| function updateScoreUI() { | |
| scoreXEl.innerText = scores.x; | |
| scoreOEl.innerText = scores.o; | |
| } | |
| /* --- Win/Draw Logic --- */ | |
| function checkWin(currentClass) { | |
| return WINNING_COMBINATIONS.some(combination => { | |
| const isWin = combination.every(index => { | |
| return cellElements[index].classList.contains(currentClass); | |
| }); | |
| if (isWin) { | |
| highlightWinningCells(combination); | |
| } | |
| return isWin; | |
| }); | |
| } | |
| function highlightWinningCells(combination) { | |
| combination.forEach(index => { | |
| cellElements[index].classList.add('win'); | |
| }); | |
| } | |
| function isDraw() { | |
| return [...cellElements].every(cell => { | |
| return cell.classList.contains(X_CLASS) || cell.classList.contains(O_CLASS); | |
| }); | |
| } | |
| function endGame(draw) { | |
| gameActive = false; | |
| if (draw) { | |
| statusText.innerText = "Empate! Ninguém venceu."; | |
| statusText.style.color = "#94a3b8"; | |
| } else { | |
| const winner = oTurn ? "O" : "X"; | |
| const color = oTurn ? "var(--accent-o)" : "var(--accent-x)"; | |
| statusText.innerHTML = `Vencedor: <span style="color: ${color}; font-weight:bold">${winner}</span>!`; | |
| // Update Score | |
| if (oTurn) scores.o++; | |
| else scores.x++; | |
| updateScoreUI(); | |
| // Confetti Effect (Simple JS implementation) | |
| createConfetti(); | |
| } | |
| // Remove click listeners to prevent further moves | |
| cellElements.forEach(cell => cell.removeEventListener('click', handleClick)); | |
| } | |
| function restartGame() { | |
| startGame(); | |
| } | |
| /* --- Visual Effects (Confetti) --- */ | |
| function createConfetti() { | |
| const colors = ['#00e5ff', '#ff007f', '#ffffff']; | |
| for (let i = 0; i < 50; i++) { | |
| const confetti = document.createElement('div'); | |
| confetti.style.position = 'fixed'; | |
| confetti.style.width = '10px'; | |
| confetti.style.height = '10px'; | |
| confetti.style.backgroundColor = colors[Math.floor(Math.random() * colors.length)]; | |
| confetti.style.left = Math.random() * 100 + 'vw'; | |
| confetti.style.top = '-10px'; | |
| confetti.style.zIndex = '1000'; | |
| confetti.style.borderRadius = '50%'; | |
| confetti.style.transition = 'top 2s ease-out, transform 2s ease-out, opacity 2s ease-out'; | |
| document.body.appendChild(confetti); | |
| setTimeout(() => { | |
| confetti.style.top = '110vh'; | |
| confetti.style.transform = `rotate(${Math.random() * 360}deg)`; | |
| confetti.style.opacity = '0'; | |
| }, 100); | |
| setTimeout(() => { | |
| confetti.remove(); | |
| }, 2000); | |
| } | |
| } | |
| </script> | |
| </body> | |
| </html> |