Skip to content

Commit

Permalink
Merge pull request #2938 from psykat1116/main
Browse files Browse the repository at this point in the history
Add New Game : [Guess The Weapon]
  • Loading branch information
kunjgit authored Oct 4, 2023
2 parents 5c5c34e + b273c42 commit b3f6e00
Show file tree
Hide file tree
Showing 40 changed files with 481 additions and 1 deletion.
Binary file added Games/Guess_The_Weapon/Asset/AA-12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/AK-47.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/AKM.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/AS50.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/AUG.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/AWM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/Banelli.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/BarretM82.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/China_Lake.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/Daewoo_K3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/DesertEagle.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/F2000.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/FAMAS.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/FIM92-Stinger.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/KAR98K.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/LAW80.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/M16A4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/M249.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/M4Carbin.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/M79.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/MG42.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/Mossberg930.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/P-90.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/PKP.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/Panzerschreck.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Guess_The_Weapon/Asset/RPG-7.png
Binary file added Games/Guess_The_Weapon/Asset/SA80.jpg
Binary file added Games/Guess_The_Weapon/Asset/SCARL.jpg
Binary file added Games/Guess_The_Weapon/Asset/SPAS12.jpg
Binary file added Games/Guess_The_Weapon/Asset/SVD_Dragunov.jpg
Binary file added Games/Guess_The_Weapon/Asset/XM8.jpg
Binary file added Games/Guess_The_Weapon/Asset/rpd.jpg
Binary file added Games/Guess_The_Weapon/Image/icon.png
40 changes: 40 additions & 0 deletions Games/Guess_The_Weapon/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# **Guess The Weapon**

---

<br>

## **Description 📃**

It is a weapon Guessing Game. By this you can came to about lots of new weapon from WWII,PUBG,COD etc.

-

## **functionalities 🎮**

You will get five weapons to guess. You have to guess the weapon by looking at the image of the weapon. You will get 3 chances to guess the weapon. If you guess the weapon correctly you will get 3 points. If you guess the weapon incorrectly you will lose 1 points. If you guess the weapon correctly in the first chance you will get 3 points. If you guess the weapon correctly in the second chance you will get 2 points. If you guess the weapon correctly in the third chance you will get 1 points. If you guess the weapon incorrectly in the first chance you will lose 1 points. If you guess the weapon incorrectly in the second chance you will lose 1 points. If you guess the weapon incorrectly in the third chance you will lose 1 point and get 0 point.
<br>

## **How to play? 🕹️**

First click the start button. Then you will get five weapons to guess. There will be also a mask over it. You have to identify them by looking at the small portion of the image. You can always show more portion by clicking into the hint button but you will lose one point each time. Again for each wrong ans you will lose one point. If you give wrong answer each time you will get point zero and move to the next question. After ending you can see your score. You can also play again by clicking the play again button.

-

<br>

## **Screenshots 📸**

<br>
![image](../../assets/images/Guess_The_Weapon.png)

<br>

## **Working video 📹**

<!-- add your working video over here -->

<br>

## **Creator**
[Saikat Samanta](https://github.com/psykat1116)
52 changes: 52 additions & 0 deletions Games/Guess_The_Weapon/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="./style.css" />
<link rel="icon" type="image/png" href="./Image/icon.png" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css"
crossorigin="anonymous"
/>
<title>Guess The Weapon - A Game To Get Familiar With Weapons</title>
</head>
<body>
<div id="intro">
<h1>Guess The Weapon</h1>
<p>
This is a guess game for guessing the correct name of the weapon. You
will given five images and You will get three chance and to identify it.
In each chance you can see a larger picture than before.
</p>
<button id="start_btn">
Lets Start<i class="fa-solid fa-arrow-right"></i>
</button>
</div>
<div id="game" class="showResult">
<div id="image_box">
<div id="mask"></div>
<img src="" alt="Weapon" id="image" />
</div>
<ul>
<li id="opt1">Value1</li>
<li id="opt2">Value2</li>
<li id="opt3">Value3</li>
<li id="opt4">Value4</li>
</ul>
<div class="option">
<button id="hint_btn">Hint<i class="fa-regular fa-face-smile-wink"></i></button>
<button id="next_ques">
Next<i class="fa-solid fa-arrow-right"></i>
</button>
</div>
</div>
<div id="result" class="showReplay">
<h1>Awesome you are a Pro Player<br />Your score is 5</h1>
<button id="replay">Play Again<i class="fa-solid fa-play"></i></button>
</div>
<script src="./info.js"></script>
<script src="./script.js"></script>
</body>
</html>
34 changes: 34 additions & 0 deletions Games/Guess_The_Weapon/info.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

138 changes: 138 additions & 0 deletions Games/Guess_The_Weapon/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
const startBtn = document.getElementById('start_btn');
const image = document.getElementById("image");
const replayBtn = document.getElementById("replay");
const options = document.querySelectorAll("#game ul li");
const nextBtn = document.getElementById("next_ques");
const resultInfo = document.querySelector("#result h1");
const gameBox = document.getElementById("game");
const opt1 = document.getElementById("opt1");
const opt2 = document.getElementById("opt2");
const opt3 = document.getElementById("opt3");
const opt4 = document.getElementById("opt4");
const intro = document.getElementById('intro');
const showHint = document.getElementById("hint_btn");
const ansBody = document.getElementById("result");
const maskImg = document.getElementById("mask");
let question = [], i = 0, score = 0, wrongCount = 0, clickCount = 0;

// Function to start the game by clicking the start button

startBtn.addEventListener('click', () => {
intro.classList.add('fadeOut');
initQuestions();
gameBox.classList.remove("showResult");
});

// Array Of Objects For Questions And Answers

const initQuestions = () => {
question = [];
i = 0; score = 0; clickCount = 0;wrongCount = 0;
while (question.length < 5) {
const randomInd = Math.floor(Math.random() * info.length);
if (!question.includes(randomInd)) {
question.push(randomInd);
}
}
changeQuestion(i);
}

// Function For Changing The Active Class

options.forEach((option) => {
option.addEventListener("click", () => {
options.forEach((opt) => {
opt.classList.remove("active");
})
option.classList.add("active");
})
});

// Function For Changing The Question

const changeQuestion = (i) => {
image.src = info[question[i]].img_src;
opt1.textContent = info[question[i]].option1;
opt2.textContent = info[question[i]].option2;
opt3.textContent = info[question[i]].option3;
opt4.textContent = info[question[i]].option4;
}

// Function For Checking The Answer And Deside the correct Answer and Wrong Answer and give score to the user

nextBtn.addEventListener("click", () => {
let selected = document.querySelector(".active");
if (!selected) {
alert("Please select an option");
return;
}
if (selected.textContent === info[question[i]].answer) {
i++;
score += (3 - wrongCount);
if (i === 5) {
resultInfo.textContent = `Your Score is ${score}`;
gameBox.classList.add("showResult");
ansBody.classList.remove("showReplay");
options.forEach((opt) => {
opt.classList.remove("active");
})
initQuestions();
return;
}
clickCount = 0;
maskImg.style.height = "60%";
maskImg.style.width = "80%";
changeQuestion(i);
options.forEach((opt) => {
opt.classList.remove("active");
})
}
else {
alert("Wrong Answer");
wrongCount++;
if (wrongCount === 3) {
i++;
if (i == 5) {
resultInfo.textContent = `Your Score is ${score}`;
gameBox.classList.add("showResult");
ansBody.classList.remove("showReplay");
options.forEach((opt) => {
opt.classList.remove("active");
})
initQuestions();
return;
}
clickCount = 0;
wrongCount = 0;
maskImg.style.height = "60%";
maskImg.style.width = "80%";
changeQuestion(i);
options.forEach((opt) => {
opt.classList.remove("active");
})
}
}
})

// Function For Giving Hint To The User

showHint.addEventListener("click", () => {
if (clickCount === 0) {
maskImg.style.height = info[question[i]].maskh;
maskImg.style.width = info[question[i]].maskw;
clickCount++;
score--;
} else {
maskImg.style.height = "0%";
maskImg.style.width = "0%";
score--;
}
})

// Function For Restart The Game By Showing The Main Screen

replayBtn.addEventListener("click", () => {
initQuestions();
ansBody.classList.add("showReplay");
intro.classList.remove('fadeOut');
})
Loading

0 comments on commit b3f6e00

Please sign in to comment.