diff --git a/Games/MathQuiz/Readme.md b/Games/MathQuiz/Readme.md new file mode 100644 index 0000000000..b6f45ec36d --- /dev/null +++ b/Games/MathQuiz/Readme.md @@ -0,0 +1,38 @@ +# **MathQuiz** + + +## **Description 📃** +It is a basic mathematical quiz. + + +
+ +## **Functionalities 🎮** + +Player need to find the correct answer to the maximum number of questions within 30 seconds. + +
+ +## **How to play? 🕹ī¸** + +1. Start the quiz on your preferred platform. +2. Click on the start button to start the quiz. +3. Your goal is to answer maximum number of questions within 30 seconds. + + +
+ +## **Installation** +1. Clone or download the repository. +2. Navigate to the downloaded repository. +3. Open index.html with live server. + + + + +
+ +## **Screenshots 📸** + +
+Game Screenshot diff --git a/Games/MathQuiz/index.html b/Games/MathQuiz/index.html new file mode 100644 index 0000000000..669af26fd4 --- /dev/null +++ b/Games/MathQuiz/index.html @@ -0,0 +1,26 @@ + + + + Math Quiz Game + + + +
+

Math Quiz Game

+
+

Welcome to the Math Quiz Game! You have 30 seconds to answer as many questions as you can. Good luck!

+ +
+ +
+ + + + diff --git a/Games/MathQuiz/script.js b/Games/MathQuiz/script.js new file mode 100644 index 0000000000..01ebaf3432 --- /dev/null +++ b/Games/MathQuiz/script.js @@ -0,0 +1,78 @@ +let correctAnswers = 0; +let wrongAnswers = 0; +let currentQuestion; +let gameStarted = false; +let timer; +let timeLeft = 30; + +function startGame() { + document.getElementById('instructions').style.display = 'none'; + document.getElementById('game').style.display = 'block'; + if (!gameStarted) { + gameStarted = true; + generateQuestion(); + updateTimer(); + timer = setInterval(updateTimer, 1000); + setTimeout(endGame, 20000); + } +} + +function generateQuestion() { + const num1 = Math.floor(Math.random() * 10) + 1; + const num2 = Math.floor(Math.random() * 10) + 1; + const operations = ['+', '-', '*', '/']; + const operation = operations[Math.floor(Math.random() * operations.length)]; + + if (operation === '/' && num1 % num2 !== 0) { + generateQuestion(); // Avoid division questions with remainders + return; + } + + currentQuestion = { num1, num2, operation }; + document.getElementById('question').innerText = `What is ${num1} ${operation} ${num2}?`; +} + +function submitAnswer() { + const answer = parseFloat(document.getElementById('answer').value); + let correctAnswer; + + switch (currentQuestion.operation) { + case '+': + correctAnswer = currentQuestion.num1 + currentQuestion.num2; + break; + case '-': + correctAnswer = currentQuestion.num1 - currentQuestion.num2; + break; + case '*': + correctAnswer = currentQuestion.num1 * currentQuestion.num2; + break; + case '/': + correctAnswer = currentQuestion.num1 / currentQuestion.num2; + break; + } + + if (answer === correctAnswer) { + correctAnswers++; + } else { + wrongAnswers++; + } + + document.getElementById('answer').value = ''; + generateQuestion(); +} + +function updateTimer() { + if (timeLeft > 0) { + document.getElementById('timer').innerText = `Time left: ${timeLeft} seconds`; + timeLeft--; + } else { + clearInterval(timer); + } +} + +function endGame() { + clearInterval(timer); + gameStarted = false; + document.getElementById('result').innerText = 'Time is up!'; + document.getElementById('score').innerText = `Correct Answers: ${correctAnswers}, Wrong Answers: ${wrongAnswers}`; +} diff --git a/Games/MathQuiz/styles.css b/Games/MathQuiz/styles.css new file mode 100644 index 0000000000..4633931a17 --- /dev/null +++ b/Games/MathQuiz/styles.css @@ -0,0 +1,60 @@ +body { + font-family: Arial, sans-serif; + text-align: center; + background-color: #f0f0f0; + margin: 0; + padding: 20px; + background-image: url("https://png.pngtree.com/thumb_back/fh260/background/20200530/pngtree-cute-hand-drawn-style-mathematics-education-pink-plaid-background-image_337364.jpg"); + background-repeat: no-repeat; + background-size: cover; + background-attachment: fixed; +} + +#game-container { + background-color: rgba(255, 255, 255, 0.8); + border: 1px solid #ccc; + border-radius: 10px; + padding: 40px; + width: 500px; + margin: 50px auto; + box-shadow: 0 0 20px rgba(0, 0, 0, 0.2); +} + +h1 { + color: #333; +} + +#question { + font-size: 24px; + margin-bottom: 20px; +} + +#answer { + width: 100px; + padding: 5px; + font-size: 16px; +} + +button { + padding: 10px 20px; + font-size: 16px; + margin-top: 10px; +} + +#result, #score, #timer { + margin-top: 20px; + font-size: 18px; +} + +#instructions { + font-size: 18px; + background-color: rgba(255, 255, 255, 0.8); + border-radius: 10px; + padding: 20px; +} + +#game { + background-color: rgba(255, 255, 255, 0.8); + border-radius: 10px; + padding: 20px; +} diff --git a/README.md b/README.md index 7275580781..ddc78baef1 100644 --- a/README.md +++ b/README.md @@ -187,7 +187,7 @@ This repository also provides one such platforms where contributers come over an | [CSS Select](https://github.com/kunjgit/GameZone/tree/main/Games/CSS_Select) | [Squid](https://github.com/kunjgit/GameZone/tree/main/Games/Squid_Game) | [Flip Coin](https://github.com/kunjgit/GameZone/tree/main/Games/Flip_Coin) | [Witty Word Quest](https://github.com/kunjgit/GameZone/tree/main/Games/witty_word_quest) | [Typing Game](https://github.com/Ishan-77/GameZone/tree/main/Games/Typing_Game) | | [numeral-whiz](https://github.com/Ishan-77/GameZone/tree/main/Games/numeral-whiz) | [candy_match](https://github.com/kunjgit/GameZone/tree/main/Games/Candy_Match_Saga) | [Crossy_Road](https://github.com/tanujbordikar/GameZone/tree/Crossy_Road) | [HueHero](https://github.com/kunjgit/GameZone/tree/main/Games/HueHero) | [Puzzel_Winner](https://github.com/kunjgit/GameZone/tree/main/Games/Puzzel_Winner) | | [Emoji_Intruder](https://github.com/kunjgit/GameZone/tree/main/Games/Emoji_Intruder) | [Guess The Weapon](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_The_Weapon) | [Guess Who](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_Who) | [Pop My Balloon](https://github.com/kunjgit/GameZone/tree/main/Games/Pop_My_Balloon) | [Color_Blast](https://github.com/kunjgit/GameZone/tree/main/Games/Color_Blast) | -| [Maze_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Maze_Game) | [Coloron](https://github.com/kunjgit/GameZone/tree/main/Games/Coloron) | [PenPointerFight](https://github.com/kunjgit/GameZone/tree/main/Games/PenPointerFight) | +| [Maze_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Maze_Game) | [Coloron](https://github.com/kunjgit/GameZone/tree/main/Games/Coloron) | [PenPointerFight](https://github.com/kunjgit/GameZone/tree/main/Games/PenPointerFight) | [MathQuiz](https://github.com/kunjgit/GameZone/tree/main/Games/MathQuiz) | | [Emoji_Intruder](https://github.com/kunjgit/GameZone/tree/main/Games/Emoji_Intruder) | [Guess The Weapon](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_The_Weapon) | [Guess Who](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_Who) | | | | [Emoji_Intruder](https://github.com/kunjgit/GameZone/tree/main/Games/Emoji_Intruder) | [Guess The Weapon](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_The_Weapon) | [Guess Who](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_Who) | [Pop My Balloon](https://github.com/kunjgit/GameZone/tree/main/Games/Pop_My_Balloon) | | diff --git a/assets/images/MathQuiz.png b/assets/images/MathQuiz.png new file mode 100644 index 0000000000..7460942485 Binary files /dev/null and b/assets/images/MathQuiz.png differ diff --git a/assets/js/gamesData.json b/assets/js/gamesData.json index 169901237d..4804631e5d 100644 --- a/assets/js/gamesData.json +++ b/assets/js/gamesData.json @@ -2088,7 +2088,6 @@ "gameTitle": "Guess_The_Song", "gameUrl": "Guess_The_Song", "thumbnailUrl": "Guess_The_Song.png" - } } diff --git a/assets/js/index.js b/assets/js/index.js index 52ef95db1b..86f599b40f 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -4,7 +4,7 @@ const generateLiTags = (gamesData, searchText = "") => { const liTags = []; searchText = searchText.trim().toLowerCase(); // Trim whitespace and convert to lowercase - for (let tagNumber = 1; tagNumber <= 416; tagNumber++) { + for (let tagNumber = 1; tagNumber <= 417; tagNumber++) { const gameData = gamesData[tagNumber.toString()]; if (gameData) {