Skip to content
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

Added Magic 8 Ball Game #4689

Merged
merged 11 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Games/Magic_8_ball/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
![alt preview image](./asset/Magic_8_ball.png)

# **MAGIC 8 BALL**

## **Description 📃**

Ask the Magical 8 Ball fortune teller yes or no questions for accurate predictions about your future!

## **functionalities 🎮**
- Ask your Questions
- Get predicted Answer

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

- Enter your question in the input textarea
- Press on the ASK button
- View Magic ball prediction
- Press CLEAR button to clear the textarea and ask another question!

<!-- ## **Screenshots 📸** -->
<!-- ![image](url) -->

<!-- ## **Working video 📹** -->
<!--![video](./asset/Magic_8_ball.mp4) -->
<!-- add your working video over here -->
Binary file added Games/Magic_8_ball/asset/Magic_8_ball.mp4
Binary file not shown.
Binary file added Games/Magic_8_ball/asset/Magic_8_ball.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Games/Magic_8_ball/asset/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Containes asset used on readme page page of this game repository!
52 changes: 52 additions & 0 deletions Games/Magic_8_ball/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" />
<title>Document</title>

<link rel="stylesheet" href="style.css" />
<script src="script.js" defer></script>
</head>
<body>
<h1>MAGIC 8 BALL🔮</h1>
<div class="container">
<div class="magic-ball">
<div class="answer" id="response">💤</div>
</div>
<div class="question">
<textarea
name=""
placeholder="⚡ask your question here⚡"
id="user-text"
></textarea>
<br /><br />
<div class="buttons">
<div class="multi-color-border">
<button id="ask">ASK✨</button>
</div>
<div class="multi-color-border">
<button id="clear">CLEAR💭</button>
</div>
</div>
</div>
</div>

<footer>
<p>
🪄Created By
<a href="https://github.com/Monika5S" target="_blank">Monika</a> with 💜
View on
<a
href="https://github.com/kunjgit/GameZone/tree/main/Games/Magic_8_Ball"
target="_blank"
>Github</a
>
🟠 GSSOC'24 ,
<a href="https://github.com/kunjgit/GameZone" target="_blank"
>GameZone</a
>Project 🎮
</p>
</footer>
</body>
</html>
59 changes: 59 additions & 0 deletions Games/Magic_8_ball/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
function clearMagicBall() {
document.querySelector("#response").innerHTML = "💤";
}

function clearText() {
document.querySelector("textarea").value = "";
}

function ToggleAnimation() {
var magic_ball_class = document.querySelector(".magic-ball");
magic_ball_class.classList.contains("animate_ball")
? magic_ball_class.classList.remove("animate_ball")
: magic_ball_class.classList.add("animate_ball");
}

function showAnswer() {
var answers = [
"It is certain",
"It is decidedly so",
"Without a doubt",
"Yes definitely",
"You may rely on it",
"As I see it, yes",
"Most likely",
"Outlook good",
"Yes",
"Signs point to yes",
"Ask again later",
"Don't count on it",
"My reply is no",
"My sources say no",
"Outlook not so good",
"Very doubtful",
];

var magic_n = Math.floor(Math.random() * answers.length);
// alert(magic_n);
setTimeout(() => {
ToggleAnimation();
document.querySelector("#response").innerHTML = "" + answers[magic_n];
}, 3000);
}

function AskMagicBall(event) {
var user_text = document.querySelector("#user-text").value;
// alert(user_text);
if (user_text == "" || user_text == " " || user_text.length <= 3) {
alert("invalid input💭...ask question with more than 3 word!");
} else {
clearMagicBall();
ToggleAnimation();
showAnswer();
}
}
document.querySelector("#ask").addEventListener("click", AskMagicBall);
document.querySelector("#clear").addEventListener("click", () => {
clearMagicBall();
clearText();
});
163 changes: 163 additions & 0 deletions Games/Magic_8_ball/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
html {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}

h1 {
font-size: 45px;
}

body {
background: linear-gradient(rgb(115, 182, 254), rgb(198, 255, 198));
text-align: center;
font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
}

a {
text-decoration: none;
color: blueviolet;
}

a:hover {
text-decoration: underline;
}

.container {
display: flex;
justify-content: center;
column-gap: 5%;
padding: 30px 0;
align-items: center;
}

.magic-ball {
width: 200px;
height: 200px;
font-size: 21px;
font-weight: 700;
color: rgb(56, 25, 56);
background-color: rgb(255, 247, 190);
display: flex;
align-items: center;
justify-content: center;
border: 70px solid rgb(56, 25, 56);
border-radius: 50%;
}

.animate_ball {
background: conic-gradient(from var(--a),
rgb(121, 83, 130) 20%,
rgb(3, 69, 66) 70%,
rgb(118, 55, 150) 100%);

animation: animate 1s linear infinite;
}

.buttons {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px;
}

button,
textarea {
transition: transform 1s ease, opacity 1s ease !important;
padding: 10px 20px;
border-radius: 10px;
border: none;
background: whitesmoke;
color: turquoise;
font-weight: 700;
font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
}

button:hover {
color: rgb(162, 232, 0);
font-weight: 700;
}

textarea {
border: 4px solid rgb(3, 206, 148);
width: 300px;
height: 100px;
}

textarea:focus {
outline: none;
border: 4px solid rgb(172, 70, 255);
}

.question {
width: fit-content;
box-shadow: 0 0 3px rgb(132, 132, 132);
border-radius: 8px;
padding: 3%;
}

.multi-color-border {
width: fit-content;
margin: 0 auto;
padding: 3px;
border-radius: 8px;
background: conic-gradient(from var(--a),
rgb(219, 208, 2) 20%,
rgb(0, 178, 249) 70%,
rgb(219, 208, 2) 100%);
animation: animate 5s linear infinite;
}

.multi-color-border:hover {
transform: scale(1.1);
box-shadow: 0px 0px 5px rgb(234, 231, 255);

}

footer {
margin: 20px auto;
border-radius: 8px;
padding: 5px 10px;
max-width: fit-content;
box-shadow: 0 0 3px rgb(132, 132, 132);
}

@media (max-width:780px) {
.container {
width: 100%;
display: flex;
row-gap: 30px;
align-items: center;
justify-content: center;
flex-direction: column;
}

.magic-ball {
width: 200px;
height: 200px;
border: 40px solid rgb(56, 25, 56);
}

textarea {
border: 4px solid rgb(3, 206, 148);
width: 250px;
height: 50px;
}
}

@property --a {
syntax: "<angle>";
inherits: false;
initial-value: 0deg;
}

@keyframes animate {
0% {
--a: 0deg;
}

100% {
--a: 360deg;
}
}
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -844,10 +844,9 @@ This repository also provides one such platforms where contributers come over an
|[Tic-tac-toe](https://github.com/kunjgit/GameZone/tree/main/Games/Tic-tac-toe)|
|[Quest_For_Riches](https://github.com/kunjgit/GameZone/tree/main/Games/Quest_For_Riches)|
| [IKnowYou-Mind-Reading-Game](https://github.com/kunjgit/GameZone/tree/main/Games/IKnowYou-Mind-Reading-Game) |
| [Tic_Tac_Toe_Neon](https://github.com/kunjgit/GameZone/tree/main/Games/Tic_Tac_Toe_Neon) |
| [Tic_Tac_Toe_Neon](https://github.com/kunjgit/GameZone/tree/main/Games/Tic_Tac_Toe_Neon) | [Magic_8_ball_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Magic_8_ball) |
| [Catch_Craze](https://github.com/kunjgit/GameZone/tree/main/Games/Catch_Craze) |


</center>

<br>
Expand Down
Binary file added assets/images/Magic_8_ball.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading