-
Notifications
You must be signed in to change notification settings - Fork 843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Harry Potter Quiz Game #5140
Merged
Merged
Harry Potter Quiz Game #5140
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# **Harry_Potter_Wizard_Quiz** | ||
|
||
--- | ||
|
||
<br> | ||
|
||
## **Description 📃** | ||
This game is a quiz that asks a series of 10 questions related to the Harry Potter book series. | ||
- | ||
|
||
## **functionalities 🎮** | ||
This is a quiz game. | ||
- | ||
<br> | ||
|
||
## **How to play? 🕹️** | ||
We just have to click on the start button and the game will start playing automatically. | ||
- | ||
|
||
<br> | ||
|
||
## **Screenshots 📸** | ||
|
||
<br> | ||
![Screenshot 2024-08-09 145254](https://github.com/user-attachments/assets/1062e08e-10c2-4201-b8b7-f71f29f4bf5d) | ||
|
||
![Screenshot 2024-08-09 141828](https://github.com/user-attachments/assets/781ade96-b615-48a3-abb0-f39e8cef365f) | ||
|
||
![Screenshot 2024-08-09 144901](https://github.com/user-attachments/assets/be252ff9-c94e-432f-a745-212aa05f8ca8) | ||
|
||
|
||
<br> | ||
|
||
## **Working video 📹** | ||
|
||
https://github.com/user-attachments/assets/fee060d2-bed3-46d9-b694-10564e3636db | ||
|
||
|
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Harry Potter Wizard Quiz Game</title> | ||
<link rel="stylesheet" href="styles.css"> | ||
</head> | ||
|
||
<body> | ||
<video autoplay muted loop id="background-video"> | ||
<source src="background.mp4" type="video/mp4"> | ||
Your browser does not support the video tag. | ||
</video> | ||
<div class="container"> | ||
<h1>Harry Potter Wizard Quiz Game</h1> | ||
<div id="question-container"> | ||
<p id="question"></p> | ||
<div id="answers"></div> | ||
</div> | ||
<div class="status"> | ||
<p>Score: <span id="score">0</span></p> | ||
<p>Time Left: <span id="timer">30</span> seconds</p> | ||
</div> | ||
</div> | ||
<script src="script.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
// Example data | ||
const questions = [ | ||
{ | ||
question: "How many people transformed into Harry Potter in the last book when Harry needed to be moved to the Weasley's house?", | ||
answers: ["Seven", "Five", "Three", "Nine"], | ||
correct: "Seven", | ||
}, | ||
{ | ||
question: "What was the prize money of the Triwizard Tournament when Harry took part in it?", | ||
answers: [ "500 Galleons", "2000 Galleons","1000 Galleons", "750 Galleons"], | ||
correct: "1000 Galleons", | ||
}, | ||
{ | ||
question: "Who gifted Harry his very first broomstick?", | ||
answers: [ "Hagrid","Sirius Black", "Professor McGonagall", "Dumbledore"], | ||
correct: "Sirius Black", | ||
}, | ||
{ | ||
question: "What animal did the imposter Mad-Eye Moody convert Malfoy into?", | ||
answers: ["Rat", "Cat", "Toad","Ferret" ], | ||
correct: "Ferret", | ||
}, | ||
{ | ||
question: "What was the first name of Professor Flitwick?", | ||
answers: ["Filius", "Severus", "Albus", "Gilderoy"], | ||
correct: "Filius", | ||
}, | ||
{ | ||
question: "What was the favourite animal of Dolores Umbridge?", | ||
answers: ["Owl","Cat", "Rabbit", "Snake"], | ||
correct: "Cat", | ||
}, | ||
{ | ||
question: "What kind of creature was Professor Firenze?", | ||
answers: [ "Goblin", "Elf","Centaur", "Werewolf"], | ||
correct: "Centaur", | ||
}, | ||
{ | ||
question: "What was James Potter's Animagus form?", | ||
answers: ["Stag", "Dog", "Wolf", "Bear"], | ||
correct: "Stag", | ||
}, | ||
{ | ||
question: "What was the color of Harry Potter's eyes?", | ||
answers: [ "Blue", "Brown","Green", "Gray"], | ||
correct: "Green", | ||
}, | ||
{ | ||
question: "What is the name of Harry Potter's pet owl?", | ||
answers: ["Hedwig", "Scabbers", "Crookshanks", "Fawkes"], | ||
correct: "Hedwig", | ||
}, | ||
|
||
|
||
]; | ||
|
||
let currentQuestionIndex = 0; | ||
let score = 0; | ||
let timer; | ||
const timeLimit = 150; | ||
|
||
document.addEventListener("DOMContentLoaded", () => { | ||
startGame(); | ||
}); | ||
|
||
function startGame() { | ||
score = 0; | ||
currentQuestionIndex = 0; | ||
document.getElementById("score").textContent = score; | ||
startTimer(); | ||
showQuestion(); | ||
} | ||
|
||
function showQuestion() { | ||
const question = questions[currentQuestionIndex]; | ||
document.getElementById("question").textContent = question.question; | ||
const answersContainer = document.getElementById("answers"); | ||
answersContainer.innerHTML = ""; | ||
question.answers.forEach((answer) => { | ||
const button = document.createElement("div"); | ||
button.textContent = answer; | ||
button.classList.add("answer"); | ||
button.addEventListener("click", () => checkAnswer(answer)); | ||
answersContainer.appendChild(button); | ||
}); | ||
} | ||
|
||
function checkAnswer(selectedAnswer) { | ||
const correctAnswer = questions[currentQuestionIndex].correct; | ||
if (selectedAnswer === correctAnswer) { | ||
score += 10; | ||
document.getElementById("score").textContent = score; | ||
// Add a sound effect or animation here | ||
} else { | ||
// Add a different sound effect or animation for incorrect answers | ||
} | ||
currentQuestionIndex++; | ||
if (currentQuestionIndex < questions.length) { | ||
showQuestion(); | ||
} else { | ||
endGame(); | ||
} | ||
} | ||
|
||
function startTimer() { | ||
let timeLeft = timeLimit; | ||
document.getElementById("timer").textContent = timeLeft; | ||
timer = setInterval(() => { | ||
timeLeft--; | ||
document.getElementById("timer").textContent = timeLeft; | ||
if (timeLeft <= 0) { | ||
clearInterval(timer); | ||
endGame(); | ||
} | ||
}, 1000); | ||
} | ||
|
||
function endGame() { | ||
document.getElementById("question").textContent = "Game Over!"; | ||
document.getElementById("answers").innerHTML = ""; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Harry Potter Wizard Quiz Game</title> | ||
<link rel="stylesheet" href="styles.css"> | ||
</head> | ||
|
||
<body> | ||
<video autoplay muted loop id="background-video"> | ||
<source src="background.mp4" type="video/mp4"> | ||
Your browser does not support the video tag. | ||
</video> | ||
<div class="startup-container"> | ||
<h1>Welcome to the Harry Potter Wizard Quiz Game!</h1> | ||
<button id="start-button">Play</button> | ||
</div> | ||
<script> | ||
document.getElementById('start-button').addEventListener('click', () => { | ||
window.location.href = 'index.html'; // Redirect to the quiz game | ||
}); | ||
</script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
@font-face { | ||
font-family: HarryP-MVZ6w; | ||
src: | ||
url('fonts/HarryP-MVZ6w.ttf') format('truetype'); | ||
font-weight: normal; | ||
font-style: normal; | ||
} | ||
|
||
|
||
|
||
/* General Body Styles */ | ||
body { | ||
font-family:HarryP-MVZ6w, Arial, sans-serif; | ||
background-color: #2e2e2e; | ||
font-size: 18px; | ||
color: #f0f0f0; | ||
text-align: center; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
/* Styles for Background Video */ | ||
#background-video { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
object-fit: cover; | ||
z-index: -1; /* Place the video behind other content */ | ||
} | ||
|
||
/* Styles for Startup Page */ | ||
.startup-container { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
z-index: 1; /* Ensure the content is above the video */ | ||
} | ||
|
||
#start-button { | ||
padding: 15px 30px; | ||
font-size: 1.2em; | ||
color: #fff; | ||
background-color: #c39a1c; /* Bright color to stand out */ | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
transition: background-color 0.3s, transform 0.2s; | ||
} | ||
|
||
#start-button:hover { | ||
background-color: #e6b800; /* Slightly darker shade on hover */ | ||
} | ||
|
||
#start-button:active { | ||
transform: scale(0.98); /* Slightly shrink the button when clicked */ | ||
} | ||
|
||
/* Styles for Quiz Page */ | ||
.container { | ||
max-width: 600px; | ||
margin: auto; | ||
padding: 20px; | ||
background-color: #717679; | ||
border-radius: 10px; | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); | ||
} | ||
|
||
h1 { | ||
color:#641e1e; | ||
} | ||
|
||
#question { | ||
font-size: 1.5em; | ||
margin-bottom: 20px; | ||
} | ||
|
||
#answers { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 10px; | ||
} | ||
|
||
.answer { | ||
background-color: #444; | ||
border: 1px solid #555; | ||
border-radius: 5px; | ||
padding: 10px; | ||
cursor: pointer; | ||
transition: background-color 0.3s; | ||
} | ||
|
||
.answer:hover { | ||
background-color: #555; | ||
} | ||
|
||
.status { | ||
margin-top: 20px; | ||
font-size: 1.2em; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove 100 from the end if not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ishita-43 mam, It is needed because due to some unknown issue games after 639 are not getting rendered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, if this way it works fine we will approve
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you need to enter your game name in the readme file of the repo please do this with the link format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done