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|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Try Again - Interactive Experience</title>
|
| 7 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 8 |
+
<style>
|
| 9 |
+
* {
|
| 10 |
+
margin: 0;
|
| 11 |
+
padding: 0;
|
| 12 |
+
box-sizing: border-box;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
:root {
|
| 16 |
+
--primary-color: #6366f1;
|
| 17 |
+
--secondary-color: #8b5cf6;
|
| 18 |
+
--accent-color: #ec4899;
|
| 19 |
+
--dark-color: #1f2937;
|
| 20 |
+
--light-color: #f3f4f6;
|
| 21 |
+
--success-color: #10b981;
|
| 22 |
+
--warning-color: #f59e0b;
|
| 23 |
+
--error-color: #ef4444;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
body {
|
| 27 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 28 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 29 |
+
min-height: 100vh;
|
| 30 |
+
display: flex;
|
| 31 |
+
flex-direction: column;
|
| 32 |
+
align-items: center;
|
| 33 |
+
justify-content: center;
|
| 34 |
+
padding: 20px;
|
| 35 |
+
color: var(--dark-color);
|
| 36 |
+
overflow-x: hidden;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
.header {
|
| 40 |
+
position: absolute;
|
| 41 |
+
top: 20px;
|
| 42 |
+
left: 20px;
|
| 43 |
+
z-index: 100;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
.header a {
|
| 47 |
+
color: white;
|
| 48 |
+
text-decoration: none;
|
| 49 |
+
font-size: 14px;
|
| 50 |
+
background: rgba(255, 255, 255, 0.2);
|
| 51 |
+
padding: 8px 16px;
|
| 52 |
+
border-radius: 20px;
|
| 53 |
+
transition: all 0.3s ease;
|
| 54 |
+
backdrop-filter: blur(10px);
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
.header a:hover {
|
| 58 |
+
background: rgba(255, 255, 255, 0.3);
|
| 59 |
+
transform: translateY(-2px);
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
.container {
|
| 63 |
+
max-width: 800px;
|
| 64 |
+
width: 100%;
|
| 65 |
+
background: rgba(255, 255, 255, 0.95);
|
| 66 |
+
border-radius: 20px;
|
| 67 |
+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
| 68 |
+
padding: 40px;
|
| 69 |
+
text-align: center;
|
| 70 |
+
position: relative;
|
| 71 |
+
overflow: hidden;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
.container::before {
|
| 75 |
+
content: '';
|
| 76 |
+
position: absolute;
|
| 77 |
+
top: 0;
|
| 78 |
+
left: 0;
|
| 79 |
+
right: 0;
|
| 80 |
+
height: 5px;
|
| 81 |
+
background: linear-gradient(90deg, var(--primary-color), var(--secondary-color), var(--accent-color));
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
.emoji {
|
| 85 |
+
font-size: 80px;
|
| 86 |
+
margin-bottom: 20px;
|
| 87 |
+
animation: bounce 2s infinite;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
@keyframes bounce {
|
| 91 |
+
0%, 100% { transform: translateY(0); }
|
| 92 |
+
50% { transform: translateY(-20px); }
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
h1 {
|
| 96 |
+
font-size: 3rem;
|
| 97 |
+
margin-bottom: 20px;
|
| 98 |
+
background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
|
| 99 |
+
-webkit-background-clip: text;
|
| 100 |
+
-webkit-text-fill-color: transparent;
|
| 101 |
+
background-clip: text;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
.subtitle {
|
| 105 |
+
font-size: 1.2rem;
|
| 106 |
+
color: #6b7280;
|
| 107 |
+
margin-bottom: 30px;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
.game-area {
|
| 111 |
+
background: var(--light-color);
|
| 112 |
+
border-radius: 15px;
|
| 113 |
+
padding: 30px;
|
| 114 |
+
margin-bottom: 30px;
|
| 115 |
+
min-height: 200px;
|
| 116 |
+
display: flex;
|
| 117 |
+
flex-direction: column;
|
| 118 |
+
align-items: center;
|
| 119 |
+
justify-content: center;
|
| 120 |
+
position: relative;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
.target {
|
| 124 |
+
width: 60px;
|
| 125 |
+
height: 60px;
|
| 126 |
+
background: var(--primary-color);
|
| 127 |
+
border-radius: 50%;
|
| 128 |
+
position: absolute;
|
| 129 |
+
cursor: pointer;
|
| 130 |
+
transition: all 0.3s ease;
|
| 131 |
+
display: flex;
|
| 132 |
+
align-items: center;
|
| 133 |
+
justify-content: center;
|
| 134 |
+
color: white;
|
| 135 |
+
font-weight: bold;
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
.target:hover {
|
| 139 |
+
transform: scale(1.2);
|
| 140 |
+
background: var(--secondary-color);
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
.score {
|
| 144 |
+
font-size: 1.5rem;
|
| 145 |
+
font-weight: bold;
|
| 146 |
+
margin-bottom: 20px;
|
| 147 |
+
color: var(--dark-color);
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
.btn {
|
| 151 |
+
background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
|
| 152 |
+
color: white;
|
| 153 |
+
border: none;
|
| 154 |
+
padding: 15px 30px;
|
| 155 |
+
font-size: 1.1rem;
|
| 156 |
+
border-radius: 50px;
|
| 157 |
+
cursor: pointer;
|
| 158 |
+
transition: all 0.3s ease;
|
| 159 |
+
margin: 10px;
|
| 160 |
+
box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
.btn:hover {
|
| 164 |
+
transform: translateY(-3px);
|
| 165 |
+
box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
.btn:active {
|
| 169 |
+
transform: translateY(1px);
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
.btn-secondary {
|
| 173 |
+
background: linear-gradient(135deg, var(--accent-color), var(--warning-color));
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
.stats {
|
| 177 |
+
display: flex;
|
| 178 |
+
justify-content: space-around;
|
| 179 |
+
margin-top: 30px;
|
| 180 |
+
flex-wrap: wrap;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
.stat-item {
|
| 184 |
+
background: white;
|
| 185 |
+
padding: 15px 25px;
|
| 186 |
+
border-radius: 10px;
|
| 187 |
+
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
| 188 |
+
margin: 10px;
|
| 189 |
+
min-width: 120px;
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
.stat-label {
|
| 193 |
+
font-size: 0.9rem;
|
| 194 |
+
color: #6b7280;
|
| 195 |
+
margin-bottom: 5px;
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
.stat-value {
|
| 199 |
+
font-size: 1.5rem;
|
| 200 |
+
font-weight: bold;
|
| 201 |
+
color: var(--primary-color);
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
.message {
|
| 205 |
+
padding: 15px;
|
| 206 |
+
border-radius: 10px;
|
| 207 |
+
margin: 20px 0;
|
| 208 |
+
font-weight: 500;
|
| 209 |
+
animation: fadeIn 0.5s ease;
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
.message.success {
|
| 213 |
+
background: rgba(16, 185, 129, 0.1);
|
| 214 |
+
color: var(--success-color);
|
| 215 |
+
border: 1px solid rgba(16, 185, 129, 0.2);
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
.message.error {
|
| 219 |
+
background: rgba(239, 68, 68, 0.1);
|
| 220 |
+
color: var(--error-color);
|
| 221 |
+
border: 1px solid rgba(239, 68, 68, 0.2);
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
@keyframes fadeIn {
|
| 225 |
+
from { opacity: 0; transform: translateY(10px); }
|
| 226 |
+
to { opacity: 1; transform: translateY(0); }
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
.particles {
|
| 230 |
+
position: absolute;
|
| 231 |
+
width: 100%;
|
| 232 |
+
height: 100%;
|
| 233 |
+
top: 0;
|
| 234 |
+
left: 0;
|
| 235 |
+
pointer-events: none;
|
| 236 |
+
overflow: hidden;
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
.particle {
|
| 240 |
+
position: absolute;
|
| 241 |
+
width: 10px;
|
| 242 |
+
height: 10px;
|
| 243 |
+
background: var(--primary-color);
|
| 244 |
+
border-radius: 50%;
|
| 245 |
+
opacity: 0.5;
|
| 246 |
+
animation: float 3s infinite ease-in-out;
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
@keyframes float {
|
| 250 |
+
0%, 100% { transform: translateY(0) translateX(0); }
|
| 251 |
+
33% { transform: translateY(-30px) translateX(30px); }
|
| 252 |
+
66% { transform: translateY(30px) translateX(-30px); }
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
@media (max-width: 768px) {
|
| 256 |
+
.container {
|
| 257 |
+
padding: 20px;
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
h1 {
|
| 261 |
+
font-size: 2rem;
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
.emoji {
|
| 265 |
+
font-size: 60px;
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
.stats {
|
| 269 |
+
flex-direction: column;
|
| 270 |
+
align-items: center;
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
.stat-item {
|
| 274 |
+
margin: 10px 0;
|
| 275 |
+
width: 80%;
|
| 276 |
+
}
|
| 277 |
+
}
|
| 278 |
+
</style>
|
| 279 |
+
</head>
|
| 280 |
+
<body>
|
| 281 |
+
<div class="header">
|
| 282 |
+
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank">Built with anycoder</a>
|
| 283 |
+
</div>
|
| 284 |
+
|
| 285 |
+
<div class="container">
|
| 286 |
+
<div class="particles" id="particles"></div>
|
| 287 |
+
|
| 288 |
+
<div class="emoji">🎯</div>
|
| 289 |
+
<h1>Try Again</h1>
|
| 290 |
+
<p class="subtitle">Click the targets as fast as you can! Miss one? No problem, just try again!</p>
|
| 291 |
+
|
| 292 |
+
<div class="message" id="message"></div>
|
| 293 |
+
|
| 294 |
+
<div class="game-area" id="gameArea">
|
| 295 |
+
<div class="score">Score: <span id="score">0</span></div>
|
| 296 |
+
<div class="target" id="target">🎯</div>
|
| 297 |
+
</div>
|
| 298 |
+
|
| 299 |
+
<div class="stats">
|
| 300 |
+
<div class="stat-item">
|
| 301 |
+
<div class="stat-label">Best Score</div>
|
| 302 |
+
<div class="stat-value" id="bestScore">0</div>
|
| 303 |
+
</div>
|
| 304 |
+
<div class="stat-item">
|
| 305 |
+
<div class="stat-label">Attempts</div>
|
| 306 |
+
<div class="stat-value" id="attempts">0</div>
|
| 307 |
+
</div>
|
| 308 |
+
<div class="stat-item">
|
| 309 |
+
<div class="stat-label">Accuracy</div>
|
| 310 |
+
<div class="stat-value" id="accuracy">0%</div>
|
| 311 |
+
</div>
|
| 312 |
+
</div>
|
| 313 |
+
|
| 314 |
+
<button class="btn" id="startBtn">Start Game</button>
|
| 315 |
+
<button class="btn btn-secondary" id="resetBtn">Reset</button>
|
| 316 |
+
</div>
|
| 317 |
+
|
| 318 |
+
<script>
|
| 319 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 320 |
+
const gameArea = document.getElementById('gameArea');
|
| 321 |
+
const target = document.getElementById('target');
|
| 322 |
+
const scoreElement = document.getElementById('score');
|
| 323 |
+
const bestScoreElement = document.getElementById('bestScore');
|
| 324 |
+
const attemptsElement = document.getElementById('attempts');
|
| 325 |
+
const accuracyElement = document.getElementById('accuracy');
|
| 326 |
+
const startBtn = document.getElementById('startBtn');
|
| 327 |
+
const resetBtn = document.getElementById('resetBtn');
|
| 328 |
+
const messageElement = document.getElementById('message');
|
| 329 |
+
const particlesContainer = document.getElementById('particles');
|
| 330 |
+
|
| 331 |
+
let score = 0;
|
| 332 |
+
let bestScore = localStorage.getItem('bestScore') || 0;
|
| 333 |
+
let attempts = 0;
|
| 334 |
+
let hits = 0;
|
| 335 |
+
let gameActive = false;
|
| 336 |
+
let targetTimeout;
|
| 337 |
+
|
| 338 |
+
bestScoreElement.textContent = bestScore;
|
| 339 |
+
|
| 340 |
+
function showMessage(text, type) {
|
| 341 |
+
messageElement.textContent = text;
|
| 342 |
+
messageElement.className = `message ${type}`;
|
| 343 |
+
setTimeout(() => {
|
| 344 |
+
messageElement.textContent = '';
|
| 345 |
+
messageElement.className = 'message';
|
| 346 |
+
}, 3000);
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
+
function createParticles() {
|
| 350 |
+
for (let i = 0; i < 20; i++) {
|
| 351 |
+
const particle = document.createElement('div');
|
| 352 |
+
particle.className = 'particle';
|
| 353 |
+
particle.style.left = Math.random() * 100 + '%';
|
| 354 |
+
particle.style.top = Math.random() * 100 + '%';
|
| 355 |
+
particle.style.animationDelay = Math.random() * 3 + 's';
|
| 356 |
+
particlesContainer.appendChild(particle);
|
| 357 |
+
}
|
| 358 |
+
}
|
| 359 |
+
|
| 360 |
+
function moveTarget() {
|
| 361 |
+
if (!gameActive) return;
|
| 362 |
+
|
| 363 |
+
const gameAreaRect = gameArea.getBoundingClientRect();
|
| 364 |
+
const maxX = gameAreaRect.width - 60;
|
| 365 |
+
const maxY = gameAreaRect.height - 60;
|
| 366 |
+
|
| 367 |
+
const randomX = Math.random() * maxX;
|
| 368 |
+
const randomY = Math.random() * maxY;
|
| 369 |
+
|
| 370 |
+
target.style.left = randomX + 'px';
|
| 371 |
+
target.style.top = randomY + 'px';
|
| 372 |
+
|
| 373 |
+
targetTimeout = setTimeout(moveTarget, 1500);
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
function startGame() {
|
| 377 |
+
if (gameActive) return;
|
| 378 |
+
|
| 379 |
+
gameActive = true;
|
| 380 |
+
score = 0;
|
| 381 |
+
attempts = 0;
|
| 382 |
+
hits = 0;
|
| 383 |
+
scoreElement.textContent = score;
|
| 384 |
+
attemptsElement.textContent = attempts;
|
| 385 |
+
accuracyElement.textContent = '0%';
|
| 386 |
+
|
| 387 |
+
startBtn.textContent = 'Game Running...';
|
| 388 |
+
startBtn.disabled = true;
|
| 389 |
+
|
| 390 |
+
showMessage('Game started! Click the target!', 'success');
|
| 391 |
+
moveTarget();
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
function endGame() {
|
| 395 |
+
gameActive = false;
|
| 396 |
+
clearTimeout(targetTimeout);
|
| 397 |
+
|
| 398 |
+
if (score > bestScore) {
|
| 399 |
+
bestScore = score;
|
| 400 |
+
localStorage.setItem('bestScore', bestScore);
|
| 401 |
+
bestScoreElement.textContent = bestScore;
|
| 402 |
+
showMessage(`New high score: ${score}!`, 'success');
|
| 403 |
+
} else {
|
| 404 |
+
showMessage(`Game over! Score: ${score}`, 'error');
|
| 405 |
+
}
|
| 406 |
+
|
| 407 |
+
startBtn.textContent = 'Start Game';
|
| 408 |
+
startBtn.disabled = false;
|
| 409 |
+
}
|
| 410 |
+
|
| 411 |
+
function resetGame() {
|
| 412 |
+
gameActive = false;
|
| 413 |
+
clearTimeout(targetTimeout);
|
| 414 |
+
|
| 415 |
+
score = 0;
|
| 416 |
+
attempts = 0;
|
| 417 |
+
hits = 0;
|
| 418 |
+
scoreElement.textContent = score;
|
| 419 |
+
attemptsElement.textContent = attempts;
|
| 420 |
+
accuracyElement.textContent = '0%';
|
| 421 |
+
|
| 422 |
+
target.style.left = '50%';
|
| 423 |
+
target.style.top = '50%';
|
| 424 |
+
target.style.transform = 'translate(-50%, -50%)';
|
| 425 |
+
|
| 426 |
+
startBtn.textContent = 'Start Game';
|
| 427 |
+
startBtn.disabled = false;
|
| 428 |
+
|
| 429 |
+
showMessage('Game reset!', 'success');
|
| 430 |
+
}
|
| 431 |
+
|
| 432 |
+
target.addEventListener('click', function() {
|
| 433 |
+
if (!gameActive) return;
|
| 434 |
+
|
| 435 |
+
hits++;
|
| 436 |
+
score += 10;
|
| 437 |
+
scoreElement.textContent = score;
|
| 438 |
+
|
| 439 |
+
// Visual feedback
|
| 440 |
+
target.style.transform = 'scale(1.5)';
|
| 441 |
+
setTimeout(() => {
|
| 442 |
+
target.style.transform = 'scale(1)';
|
| 443 |
+
}, 200);
|
| 444 |
+
|
| 445 |
+
// Move target immediately
|
| 446 |
+
clearTimeout(targetTimeout);
|
| 447 |
+
moveTarget();
|
| 448 |
+
});
|
| 449 |
+
|
| 450 |
+
gameArea.addEventListener('click', function(e) {
|
| 451 |
+
if (!gameActive || e.target === target) return;
|
| 452 |
+
|
| 453 |
+
attempts++;
|
| 454 |
+
attemptsElement.textContent = attempts;
|
| 455 |
+
|
| 456 |
+
const accuracy = attempts > 0 ? Math.round((hits / attempts) * 100) : 0;
|
| 457 |
+
accuracyElement.textContent = accuracy + '%';
|
| 458 |
+
|
| 459 |
+
if (accuracy < 30) {
|
| 460 |
+
showMessage('Keep trying! You can do better!', 'error');
|
| 461 |
+
}
|
| 462 |
+
});
|
| 463 |
+
|
| 464 |
+
startBtn.addEventListener('click', startGame);
|
| 465 |
+
resetBtn.addEventListener('click', resetGame);
|
| 466 |
+
|
| 467 |
+
// Initialize particles
|
| 468 |
+
createParticles();
|
| 469 |
+
});
|
| 470 |
+
</script>
|
| 471 |
+
</body>
|
| 472 |
+
</html>
|