Skip to content

Commit

Permalink
Merge pull request #4829 from samarsajad/king
Browse files Browse the repository at this point in the history
added king of pirates game
  • Loading branch information
kunjgit authored Jul 16, 2024
2 parents 6c261af + 74b8674 commit d952592
Show file tree
Hide file tree
Showing 7 changed files with 324 additions and 0 deletions.
48 changes: 48 additions & 0 deletions Games/King_Of_Pirates_Quiz/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# One Piece Quiz

This is a simple quiz application based on the popular anime and manga series, One Piece. The quiz tests your knowledge of the series with a set of questions. The application is built using HTML, CSS, and JavaScript.

## Table of Contents

- [Project Overview](#project-overview)
- [Features](#features)
- [Technologies Used](#technologies-used)
- [Usage](#usage)
- [Contributing](#contributing)


## Project Overview

The One Piece Quiz is a web application that presents the user with a series of questions related to One Piece. Each question has multiple choice answers, and the user can select the correct answer to proceed to the next question. At the end of the quiz, the user receives a score based on their answers.

## Features

- A series of multiple choice questions related to One Piece
- Next question button to proceed through the quiz
- Score calculation and display at the end of the quiz
- Responsive design for various screen sizes

## Technologies Used

- HTML
- CSS
- JavaScript
- Google Fonts



## Usage

1. Open the `index.html` file in your web browser.
2. Click the "Next Question" button to proceed through the quiz.
3. Select the correct answer for each question.
4. At the end of the quiz, view your score.



## Contributing

Contributions are welcome! If you would like to contribute to this project, please fork the repository and submit a pull request with your changes. Ensure that your code follows the existing code style and includes tests where applicable.



Binary file added Games/King_Of_Pirates_Quiz/background.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions Games/King_Of_Pirates_Quiz/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>One Piece Quiz</title>
<link rel="stylesheet" href="styles.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Cedarville+Cursive&family=Press+Start+2P&family=Teko:[email protected]&family=Zeyada&display=swap" rel="stylesheet">
</head>
<body style="background-image: url('../King_Of_Pirates_Quiz/background.jpg'); background-size: cover;"></body>
<div class ="heading-container">
<h1>One Piece Quiz</h1>

</div>

<div class="quiz-container">

<div id="question-container"></div>
<button id="next-btn">Next Question</button>
<div id="result"></div>
</div>
<script src="script.js"></script>
</body>
</html>
206 changes: 206 additions & 0 deletions Games/King_Of_Pirates_Quiz/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
const questions = [
{
question: "Who is the captain of the Straw Hat Pirates?",
answers: ["Luffy", "Zoro", "Sanji", "Nami"],
correctAnswer: "Luffy"
},
{
question: "What is the name of Luffy's signature attack?",
answers: ["Gum-Gum Pistol", "Gum-Gum Bazooka", "Gum-Gum Gatling", "Gum-Gum Red Hawk"],
correctAnswer: "Gum-Gum Gatling"
},
{
question: "Who is known as the 'Pirate Hunter'?",
answers: ["Luffy", "Zoro", "Sanji", "Nami"],
correctAnswer: "Zoro"
},
{
question: "Who is known as the 'King of the Pirates'?",
answers: ["Shanks", "Whitebeard", "Roger", "Kaido"],
correctAnswer: "Roger"

},
{
question: "What is the name of the Devil Fruit that Luffy eats?",
answers: ["Gum-Gum Fruit", "Fire-Fire Fruit", "Ice-Ice Fruit", "Dark-Dark Fruit"],
correctAnswer: "Gum-Gum Fruit"

},
{
question: "Who is Luffy's adoptive brother?",
answers: ["Zoro", "Ace", "Sanji", "Law"],
correctAnswer: "Ace"

},


{
question: "What is the name of Luffy's ship?",
answers: ["Polar Tang", "Going Merry", "Moby Dick", "Red Force"],
correctAnswer: "Going Merry"

},
{
question: "What is Zoro's dream?",
answers: ["To become the greatest swordsman", "To find the One Piece", "To become a famous chef", "To become a doctor"],
correctAnswer: "To become the greatest swordsman"

},
{
question: "Who is the creator of the One Piece manga and anime series?",
answers: ["Eiichiro Oda", "Akira Toriyama", "Masashi Kishimoto", "Tite Kubo"],
correctAnswer: "Eiichiro Oda"

},
{
question: "Who is the doctor of the Straw Hat Pirates?",
answers: ["Chopper", "Law", "Franky", "Brook"],
correctAnswer: "Chopper"
},
{
question: "What is the name of the island where Luffy first meets the Warlord Dracule Mihawk?",
answers: ["Water 7", "Loguetown", "Sabaody Archipelago", "Baratie"],
correctAnswer: "Baratie"

},

{
question: "Which character has the highest known bounty in the One Piece series?",
answers: ["Monkey D. Luffy", "Charlotte Katakuri", "Edward Newgate (Whitebeard)", "Marshall D. Teach (Blackbeard)"],
correctAnswer: "Edward Newgate (Whitebeard)"

},

{
question: "Who is the original owner of the Straw Hat that Luffy wears?",
answers: ["Gol D. Roger", "Shanks", "Rayleigh", "Whitebeard"],
correctAnswer: "Gol D. Roger"
},
{
question: "What is the name of the island where the One Piece treasure is said to be located?",
answers: ["Skypiea", "Raftel", "Wano", "Elbaf"],
correctAnswer: "Raftel"
},
{
question: "Which character can transform into a dragon?",
answers: ["Marco", "Kaido", "Law", "Kin'emon"],
correctAnswer: "Kaido"
},
{
question: "What is the name of Luffy's first bounty poster?",
answers: ["30,000,000 Berries", "100,000,000 Berries", "1,000,000 Berries", "10,000,000 Berries"],
correctAnswer: "30,000,000 Berries"
},
{
question: "Who is the captain of the Heart Pirates?",
answers: ["Trafalgar Law", "Eustass Kid", "X Drake", "Killer"],
correctAnswer: "Trafalgar Law"
},
{
question: "What is the name of the special technique used by Zoro, where he creates multiple sword illusions?",
answers: ["Oni Giri", "Tatsumaki", "Santoryu Ogi: Sanzen Sekai", "Asura"],
correctAnswer: "Santoryu Ogi: Sanzen Sekai"
},
{
question: "Who was the first character to defeat Luffy in a one-on-one fight?",
answers: ["Crocodile", "Arlong", "Enel", "Mihawk"],
correctAnswer: "Crocodile"
},
{
question: "What is the name of Sanji's family of assassins?",
answers: ["Baroque Works", "Big Mom Pirates", "Germa 66", "Beasts Pirates"],
correctAnswer: "Germa 66"
},
{
question: "Which character is known as the 'Magician'?",
answers: ["Buggy", "Blackbeard", "Kizaru", "Magellan"],
correctAnswer: "Magellan"
},
{
question: "Who is the current Fleet Admiral of the Marines?",
answers: ["Sengoku", "Aokiji", "Akainu", "Kizaru"],
correctAnswer: "Akainu"
},
{
question: "What is the name of the Devil Fruit eaten by Trafalgar Law?",
answers: ["Op-Op Fruit", "Soul-Soul Fruit", "Room-Room Fruit", "Ope-Ope Fruit"],
correctAnswer: "Ope-Ope Fruit"
},
{
question: "Who is the captain of the Blackbeard Pirates?",
answers: ["Blackbeard", "Shiryu", "Burgess", "Van Augur"],
correctAnswer: "Blackbeard"
},
{
question: "What is the name of the weapon used by Franky after the timeskip?",
answers: ["Coup de Vent", "General Cannon", "Iron Pirate General Franky", "Franky Radical Beam"],
correctAnswer: "Iron Pirate General Franky"
}

];
let currentQuestion = 0;
let score = 0;
let wrongAnswers = [];

const questionContainer = document.getElementById('question-container');
const nextButton = document.getElementById('next-btn');
const resultContainer = document.getElementById('result');

function displayQuestion() {
const currentQ = questions[currentQuestion];
questionContainer.innerHTML = `
<h2>${currentQ.question}</h2>
<ul>
${currentQ.answers.map(answer => `<li><input type="radio" name="answer" value="${answer}">${answer}</li>`).join('')}
</ul>
`;
}

function checkAnswer() {
const selectedAnswer = document.querySelector('input[name="answer"]:checked');
if (!selectedAnswer) return;

if (selectedAnswer.value === questions[currentQuestion].correctAnswer) {
score++;
} else {
wrongAnswers.push({
question: questions[currentQuestion].question,
correctAnswer: questions[currentQuestion].correctAnswer,
userAnswer: selectedAnswer.value
});
}

currentQuestion++;
selectedAnswer.checked = false;

if (currentQuestion < questions.length) {
displayQuestion();
} else {
showResult();
}
}

function showResult() {
questionContainer.innerHTML = '';
nextButton.style.display = 'none';

resultContainer.innerHTML = `<h3>Your Score: ${score}/${questions.length}</h3>`;
if (wrongAnswers.length > 0) {
resultContainer.innerHTML += '<h3>Incorrect Answers:</h3>';
wrongAnswers.forEach(wrong => {
resultContainer.innerHTML += `
<p><strong>Question:</strong> ${wrong.question}</p>
<p><strong>Your Answer:</strong> ${wrong.userAnswer}</p>
<p><strong>Correct Answer:</strong> ${wrong.correctAnswer}</p>
`;
});
}
}

displayQuestion();

nextButton.addEventListener('click', function() {
this.classList.add('button-clicked');
checkAnswer();
});

43 changes: 43 additions & 0 deletions Games/King_Of_Pirates_Quiz/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
body {
font-family: Arial, sans-serif;

}
.heading-container{
font-family: "Press Start 2P", system-ui;
font-weight: 400;
font-style: normal;
align-self: center;
margin-left: 27%;
font-size: 30px;

}

.quiz-container {
max-width: 600px;
margin: 20px auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
background-color: rgba(255, 255, 255, 0.7);
margin-top: 225px;
align-items: center;
font-family: "Press Start 2P", system-ui;
font-weight: 400;
font-style: normal;
}

button {
padding: 10px 20px;
margin-top: 10px;
cursor: pointer;
font-family: "Press Start 2P", system-ui;
font-weight: 400;
font-style: normal;
background-color: #23407b;;
}

button:hover {
background-color: #e48d30;
color: #080808;
}

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ This repository also provides one such platforms where contributers come over an
| [IKnowYou-Mind-Reading-Game](https://github.com/kunjgit/GameZone/tree/main/Games/IKnowYou-Mind-Reading-Game) |
|[Rock_Paper_Scissors_Neon](https://github.com/kunjgit/GameZone/tree/main/Games/Rock_Paper_Scissors_Neon)|
|[Beat_a_mole](https://github.com/kunjgit/GameZone/tree/main/Games/Beat_a_mole)|
|[King_Of_Pirates_Quiz](https://github.com/kunjgit/GameZone/tree/main/Games/King_Of_Pirates_Quiz)|
|[Catch Him](https://github.com/kunjgit/GameZone/tree/main/Games/Catch_him) |
|[Hexsweep_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Hexsweep-Game)|

Expand Down
Binary file added assets/images/King_Of_Pirates.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d952592

Please sign in to comment.