hh

HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Math-o-Cubic Arena</title> <link rel="stylesheet" href="styles.css"> <link rel="icon" href="favicon.ico"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"> </head> <body> <!-- Greeting Screen --> <div class="greeting-screen"> <i class="fa fa-heart heart-animation"></i> <!-- Sparkling Heart --> <h1>Welcome to Freaky-Arena????</h1> <p>Can you prove your worth??</p> <p>Climb up and show us what you are capable of</p> <button id="start-btn">Start Game</button> <div class="social-links"> <a href="https://www.instagram.com/aditya.cx/" target="_blank"><i class="fa-brands fa-instagram"></i></a> <a href="https://www.linkedin.com/in/aditya-bisht-80b77a324/" target="_blank"><i class="fa-brands fa-linkedin"></i></a> </div> </div> <!-- Game Screen --> <div class="game-container"> <div class="question-container"> <h2 id="question">Loading Question...</h2> </div> <div class="options-container"> <!-- Options will be loaded dynamically here --> </div> <div class="timer">Time Left: <span id="timer">15</span> seconds</div> <div> Score: <span id="score">0</span> | Streak: <span id="streak">0</span> </div> </div> <!-- Losing Screen --> <div class="losing-screen"> <h1>Game Over</h1> <p id="smarter-percentage">You are smarter than X% of people!</p> <button class="restart-btn">Try Again</button> <p class="final-message"></p> <p class="score-message"></p> <p class="credits">App created by <a href="https://www.instagram.com/aditya.cx/">Aditya Bisht</a> | <a href="https://www.linkedin.com/in/aditya-bisht-80b77a324/">LinkedIn</a></p> <p>I developed this app at the age of 16, and I want to express my gratitude for playing this game with me. I hope you will share this app with your friends!</p> </div> <script src="script.js"></script> </body> </html>
CSS
/* General Styles */ body { font-family: 'Arial', sans-serif; margin: 0; padding: 0; background-color: #1d1f2b; color: white; text-align: center; } /* Front Page Styling */ .greeting-screen { display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100vh; background-color: #2c3e50; color: white; text-align: center; } .greeting-screen h1 { font-size: 3rem; margin-bottom: 20px; } .greeting-screen p { font-size: 1.2rem; margin-bottom: 15px; /* Vertical spacing between text */ } .greeting-screen button { font-size: 1.5rem; padding: 10px 20px; background-color: #3498db; color: white; border: none; cursor: pointer; border-radius: 5px; transition: background-color 0.3s; } .greeting-screen button:hover { background-color: #2980b9; } .greeting-screen i { font-size: 3rem; /* Increase icon size */ margin-bottom: 20px; color: white; /* Icon in white for better visibility */ animation: sparkle 1.5s infinite alternate; /* Sparkle effect */ } @keyframes sparkle { 0% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.2); opacity: 0.5; } } /* Social Media Links */ .social-links a { font-size: 2rem; margin: 10px; color: white; text-decoration: none; } .social-links a:hover { color: #f39c12; } /* Game Container Styling */ .game-container { display: none; text-align: center; } .game-container .question-container { background-color: #3498db; color: white; padding: 20px; margin: 20px 0; font-size: 1.5rem; border-radius: 5px; } .game-container .options-container button { background-color: #2980b9; color: white; padding: 10px 20px; margin: 5px; border: none; cursor: pointer; border-radius: 5px; font-size: 1.2rem; } .game-container .options-container button:hover { background-color: #1f6481; } .game-container .timer { font-size: 1.5rem; margin-top: 20px; } /* Winning and Losing Screen Styling */ .winning-screen, .losing-screen { display: none; background-color: #ADD8E6; /* Light blue background */ color: black; padding: 20px; border-radius: 10px; text-align: center; margin-top: 50px; } .winning-screen h1, .losing-screen h1 { font-size: 2rem; color: black; } .final-message { font-size: 1.2rem; color: black; } .credits { font-size: 1.2rem; color: black; } .credits a { color: #000; text-decoration: underline; padding: 0 5px; } #start-btn { font-size: 1.5rem; background-color: #5c6bc0; padding: 15px 30px; border: none; border-radius: 10px; cursor: pointer; } #start-btn:hover { background-color: #3f51b5; } /* Heart Animation */ .heart-animation { font-size: 3rem; /* Larger size for better visibility */ margin-bottom: 20px; animation: sparkle 1.5s infinite alternate; color: white; } /* Responsive Design */ @media (max-width: 600px) { h1 { font-size: 2rem; } .question-container h2 { font-size: 1.2rem; } .timer { font-size: 1rem; } .options-container button { font-size: 1rem; padding: 8px 16px; } }
JAVASCRIPT
// Game Initialization document.getElementById('start-btn').addEventListener('click', startGame); let currentQuestionIndex = 0; let score = 0; let streak = 0; let timer; let timeLeft = 10; // 10 seconds for each question // List of questions let questions = [ { question: "3 + 5 = ?", options: ["12", "8", "15", "10"], correct: "8" }, { question: "6 × 7 = ?", options: ["42", "36", "28", "48"], correct: "42" }, { question: "20 ÷ 5 = ?", options: ["4", "5", "6", "3"], correct: "4" }, { question: "9 + 8 = ?", options: ["17", "18", "15", "14"], correct: "17" }, // Additional questions { question: "15 - 7 = ?", options: ["8", "9", "7", "6"], correct: "8" }, { question: "5 × 9 = ?", options: ["45", "50", "40", "55"], correct: "45" }, { question: "12 ÷ 4 = ?", options: ["3", "2", "4", "5"], correct: "3" }, { question: "18 + 6 = ?", options: ["22", "24", "20", "26"], correct: "24" }, { question: "30 - 15 = ?", options: ["15", "12", "18", "20"], correct: "15" }, { question: "8 × 3 = ?", options: ["24", "20", "22", "26"], correct: "24" }, { question: "16 ÷ 2 = ?", options: ["6", "8", "4", "10"], correct: "8" }, { question: "14 + 9 = ?", options: ["23", "22", "21", "24"], correct: "23" }, { question: "25 - 10 = ?", options: ["15", "20", "10", "5"], correct: "15" }, { question: "7 × 6 = ?", options: ["42", "36", "48", "54"], correct: "42" }, { question: '100 ÷ 4 = ?', options: ['25', '30', '20', '35'], correct: '25' } ]; function startGame() { document.querySelector('.greeting-screen').style.display = 'none'; document.querySelector('.game-container').style.display = 'block'; showQuestion(); startTimer(); } function startTimer() { timeLeft = 10; // Reset timer for each question document.getElementById('timer').textContent = timeLeft; timer = setInterval(function() { timeLeft--; document.getElementById('timer').textContent = timeLeft; if (timeLeft <= 0) { clearInterval(timer); gameOver(); } }, 1000); } function showQuestion() { let currentQuestion = questions[currentQuestionIndex]; document.getElementById('question').textContent = currentQuestion.question; let optionsHtml = ''; currentQuestion.options.forEach(option => { optionsHtml += `<button class="option-btn">${option}</button>`; }); document.querySelector('.options-container').innerHTML = optionsHtml; document.getElementById('score').textContent = score; document.getElementById('streak').textContent = streak; } // Handle answer selection document.querySelector('.options-container').addEventListener('click', function(event) { if (event.target.tagName === 'BUTTON') { let selectedOption = event.target.textContent; checkAnswer(selectedOption); } }); function checkAnswer(selectedOption) { let currentQuestion = questions[currentQuestionIndex]; if (selectedOption === currentQuestion.correct) { score += 10; streak++; } else { gameOver(); } currentQuestionIndex++; if (currentQuestionIndex < questions.length) { clearInterval(timer); showQuestion(); startTimer(); } else { gameOver(); } } function gameOver() { document.querySelector('.game-container').style.display = 'none'; document.querySelector('.losing-screen').style.display = 'block'; document.getElementById('smarter-percentage').textContent = `You are smarter than ${Math.floor(Math.random() * 100)}% of people!`; document.querySelector('.score-message').textContent = `Your score: ${score}`; document.querySelector('.final-message').textContent = 'Thanks for trying my app!'; }
Expand for more options Login