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

CREATED THE GAME ELEPHANT ANT MAN #4219

Merged
merged 14 commits into from
Jul 27, 2024
34 changes: 34 additions & 0 deletions Games/Elephant_ant_man/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# **Elephant_ant_man**

---

<br>

## **Description 📃**

It is a cuter version of the classic game rock paper scissors. It is inspired by the famous bedtime story the ant and the elephant where the ant despite his small size teaches a lesson to the elephant.
-

## **Functionalities 🎮**

->the user can select one of the three choices and a message will display on the screen if the user won or lost. if the user lost the computer gets the point and vice versa.
-
<br>

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

click on any of the three images
the computer will randomly select a choice of his own
score will be updated as you won or lost
its a endless game enjoy playing

<br>

## **Screenshots 📸**

<br>

[image](screenshot.png)


<br>
Binary file added Games/Elephant_ant_man/ant.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/Elephant_ant_man/boyy.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/Elephant_ant_man/elephant.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions Games/Elephant_ant_man/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ROCK,PAPER and SCISSORS</title>
<link rel="stylesheet" href="style.css"/>
</head>
<body>
<h1>Ant, Boy and Elephant</h1>
<div class="choices">
<div class="choice" id="Boy">
<img src="boyy.jpg">
</div>
<div class="choice" id="Elephant">
<img src="elephant.jpg">
</div>
<div class="choice" id="Ant">
<img src="ant.jpg">
</div>
</div>
<div class="scoreboard">
<div class="score">
<p id="userscore">0</p>
<p>You</p>
</div>
<div class="score">
<p id="compscore">0</p>
<p>Computer</p>
</div>
</div>
<div class="msgcontainer">
<p id="msg">Play your move!</p>
</div>
<script src="script.js"></script>
</body>
</html>
Binary file added Games/Elephant_ant_man/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 64 additions & 0 deletions Games/Elephant_ant_man/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
let userScore=0;
let compScore=0;

const choices = document.querySelectorAll(".choice");
const msg=document.querySelector("#msg");
const userScorePara=document.querySelector("#userscore");
const compScorePara=document.querySelector("#compscore");

const genCompChoice = () => {
const options=["Boy","Elephant","Ant"];
const randIdx=Math.floor(Math.random()*3);
return options[randIdx];
}
const drawGame=()=>{
console.log("It's a tie. Play again!")
msg.innerText="It's a tie. Play again!"
msg.style.backgroundColor="rgb(109, 130, 100)"
}
const showWinner=(userWin, userChoice, compChoice)=>{
if(userWin){
console.log("Congratulations! You won.")
userScore++;
userScorePara.innerText =userScore;
msg.innerText=`Congratulations! You won. ${userChoice} beats the ${compChoice}`
msg.style.backgroundColor="green";
}
else{
console.log("Sorry you lost, better luck next time.")
compScore++;
compScorePara.innerText=compScore;
msg.innerText=`Sorry you lost, better luck next time. ${userChoice} lost to the ${compChoice}`
msg.style.backgroundColor="red";
}
}

const playGame= (userChoice)=>{
console.log("userchoice = ", userChoice);
const compChoice=genCompChoice();
console.log("compChoice= ", compChoice);

if (userChoice==compChoice){
drawGame();
}else{
let userWin=true;
if(userChoice=="Boy"){
userWin=compChoice==="Elephant"? false:true;
}
else if(userChoice=="Elephant"){
userWin=compChoice==="Ant"? false:true;
}
else{
userWin=compChoice==="Boy"? false:true;
}
showWinner(userWin, userChoice, compChoice);

}
};

choices.forEach((choice)=>{
choice.addEventListener("click",()=>{
const userChoice= choice.getAttribute("id");
playGame(userChoice);
});
});
64 changes: 64 additions & 0 deletions Games/Elephant_ant_man/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
*{
margin:0;
padding:0;
text-align: center;
background-color: rgb(217, 251, 223);
}
h1 {
background-color: rgb(109, 130, 100);
color: azure;
height: 80px;
line-height: 80px;
font: 80px;

}
.choice:hover{
opacity: 0.5;
cursor:grab;
}
.choice{
height: 200px;
width: 200px;
border-radius: 50%;
}
img{
height:175px;
width:175px;
border-radius: 50%;
object-fit: cover;

}
.choices{
display:flex;
justify-content: center;
align-items: center;
gap:50px;
margin-top: 90px;
}

.scoreboard{
display:flex;
justify-content: center;
align-items: center;
gap:100px;
margin-top:40px;
font-size:40px;
color:rgb(53, 76, 53)
}
#userscore,#compscore{
font-size:60px;
}
#msg{
background-color: rgb(109, 130, 100);
color:azure;
font-size:35px;
font-style:italic;
height:60px;
display:inline;
padding: 20px;
border-radius: 1rem;

}
.msgcontainer{
margin-top: 60px;
}
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,7 @@ This repository also provides one such platforms where contributers come over an
| [LaserDarts](https://github.com/Jagpreet153/GameZone/tree/main/Games/LaserDarts)
| [Block Building](https://github.com/kunjgit/GameZone/tree/main/Games/Block_Building) |
| [Flames Game](https://github.com/kunjgit/GameZone/tree/main/Games/Flames_Game)|

| [NewsJunction](https://github.com/kunjgit/GameZone/tree/main/Games/NewsJunction) |
|[Ping_Pong_Singleplayer](https://github.com/kunjgit/GameZone/tree/main/Games/Ping_Pong_Singleplayer) |
| [MazeRunner](https://github.com/kunjgit/GameZone/tree/main/Games/MazeRunner) |
Expand All @@ -1215,6 +1216,7 @@ This repository also provides one such platforms where contributers come over an
|[Building Blocks Game](https://github.com/kunjgit/GameZone/tree/main/Games/Building_Block_Game)|
|[Cartoon character guessing game](https://github.com/kunjgit/GameZone/tree/main/Games/Cartoon_Character_Guessing_Game)|
|[Align_4_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Align_4_Game)|

|[Carrom Board Game](https://github.com/kunjgit/GameZone/tree/main/Games/carrom)|
| [Tic-Tac-Toe Game](https://github.com/kunjgit/GameZone/tree/main/Games/Tic-Tac-Toe) |
| [Number_Recall_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Number_Recall_Game) |
Expand All @@ -1239,6 +1241,8 @@ This repository also provides one such platforms where contributers come over an
| [Dsa_quiz_game](https://github.com/kunjgit/GameZone/tree/main/Games/Dsa_quiz_game) |
| [Gravity_Simulation_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Gravity_Simulation_Game) |
| [Rapid_click_frenzy](https://github.com/kunjgit/GameZone/tree/main/Games/Rapid_click_frenzy)

|[Elephant_ant_man](https://github.com/tanishkaa08/GameZone/tree/main/Games/Elephant_ant_man)
| [Catch_The_Ball](https://github.com/kunjgit/GameZone/tree/main/Games/Catch_The_Ball) |
| [Ball_in_Maze](https://github.com/kunjgit/GameZone/tree/main/Games/Ball_in_Maze) |
|[Dsa_quiz_game](https://github.com/kunjgit/GameZone/tree/main/Games/Dsa_quiz_game) |
Expand Down Expand Up @@ -1270,6 +1274,7 @@ This repository also provides one such platforms where contributers come over an
| [Bunny is Lost](https://github.com/kunjgit/GameZone/tree/main/Games/Bunny_is_Lost)|
|[Steam_Punk](https://github.com/kunjgit/GameZone/tree/main/Games/Steam_Punk)|


|[OutRun_Offline_Game](https://github.com/kunjgit/GameZone/tree/main/Games/OutRun_Offline_Game)|
|[Tower Defence Game](https://github.com/Will2Jacks/GameZoneForked/tree/Task/Games/Tower_Defence_Game)|

Expand Down Expand Up @@ -1309,8 +1314,6 @@ This repository also provides one such platforms where contributers come over an
|[Five_Nights_at_Freddys](https://github.com/kunjgit/GameZone/tree/main/Games/Five_Nights_at_Freddys)|
|[Snake_Gun_Water](https://github.com/kunjgit/GameZone/tree/main/Games/Snake_Gun_Water)|
|[Tether](https://github.com/kunjgit/GameZone/tree/main/Games/Tether)|


|[Rock Paper Scissors Lizard Spock Game](./Games/Rock_Paper_Scissors_Lizard_Spock_Game)|

|[Hangman_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Hangman_Game)|
Expand All @@ -1319,7 +1322,7 @@ This repository also provides one such platforms where contributers come over an
<br>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add this line again


<div align="center">
<h2><font size="6"><img src="https://raw.githubusercontent.com/Tarikul-Islam-Anik/Animated-Fluent-Emojis/master/Emojis/Objects/Page%20with%20Curl.png" alt="Page with Curl" width="40" height="40" /> Contributing Guideline </font></h2>
<h2><font size="6"><img src="https://raw.githubusercontent.com/Tarikul-Islam-Anik/Animated-Fluent-E|mojis/master/Emojis/Objects/Page%20with%20Curl.png" alt="Page with Curl" width="40" height="40" /> Contributing Guideline </font></h2>
</div>
<br>

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