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 Automated rock Paper Scissor #3655

Merged
merged 2 commits into from
May 25, 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
22 changes: 22 additions & 0 deletions Games/automated_rock_paper_scissor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# **Automated Rock Paper Scissor**
---

## **Description 📃**
- It a basic rock paper scissor game with an addition autoplay feature

## **functionalities 🎮**
- to be played on desktop.
<br>

## **How to play? 🕹️**
Select the option of ur choice and see the results againg the computer, additionally you can put it to auto play and watch the results as well
<br>

## **Screenshots 📸**

<br>

![image](https://github.com/kunjgit/GameZone/assets/83546205/ffe42ab9-86df-470d-b6bc-3db0c1e16e07)

<br>

175 changes: 175 additions & 0 deletions Games/automated_rock_paper_scissor/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body{
background-color: #191919;
color: white;
display: flex;
justify-content: center ;
min-height: 98vh;
align-items: center;
}
.hands{
height: 120px;
width: 120px;
font-size: 40px;
background-color: #191919;
border-radius: 50%;
border: solid white;
margin: 5px;
margin-bottom: 24px;
cursor: pointer;
}
.reset,.auto{
background-color: white;
color: black;
height: 33px;
width: 132px;
border: none;
border-radius: 10px;
font-size: larger;

}
p{
font-size: 20px;
}
h3{
font-size: 30px;
}
#myPick,#autoPick{
font-size: 40px;
}
</style>
</head>
<body>

<div>
<h1><b>Rock Paper Scissors</b> </h1>
<button class="hands" onclick="compare('✊')">✊</button>
<button class="hands" onclick="compare('🤚')">🤚</button>
<button class="hands" onclick="compare('✌️')">✌️</button>
<h3 id="result"></h3>
<p>You <span id="myPick"></span><span id="autoPick"></span> Computer</p>
<p>Wins: <span id="wins">0</span>, Losses: <span id="losses">0</span>, Ties: <span id="ties">0</span></p>

<button class="reset" onclick="resetScores()">Reset Score</button>
<button class="auto" onclick="autoPlay()">Auto Play</button>

</div>




<script>


let score={winings : 0, loss : 0, ties : 0};
let savedScore=JSON.parse(localStorage.getItem('score'));
if (savedScore){
score=savedScore;
}
updateScoreElement();


const computer=['✊','🤚','✌️'];
let myInterval;

function autoPlay(){
if(document.querySelector('.auto').innerHTML=='Auto Play'){
document.querySelector('.auto').innerHTML='Stop Play';
let choice=computer[Math.floor(Math.random()*3)];
myInterval=setInterval(function(){compare(choice)},1000)
}
else if(document.querySelector('.auto').innerHTML=='Stop Play'){
document.querySelector('.auto').innerHTML='Auto Play';
clearInterval(myInterval);
}







}

function updateScoreElement(){
document.getElementById('losses').innerHTML=score.loss;
document.getElementById('ties').innerHTML=score.ties;
document.getElementById('wins').innerHTML=score.winings;
}


function resetScores(){
score.winings=0; score.loss=0; score.ties=0;
updateScoreElement();
}


function compare(user){

updateScoreElement();

let choice=computer[Math.floor(Math.random()*3)];
document.getElementById('myPick').innerHTML=user;
document.getElementById('autoPick').innerHTML=choice;
if(user==choice){
score.ties+=1;console.log('Draw');
updateScoreElement();
document.getElementById('result').innerHTML='Draw';
}
else if(user=="🤚"){
if(choice=='✌️'){
score.loss+=1;console.log('you lose');
updateScoreElement();
document.getElementById('result').innerHTML='You Lose';
}
else{
score.winings+=1;
console.log('you win');
updateScoreElement();
document.getElementById('result').innerHTML='You Win';
}
}
else if(user=="✊"){
if(choice=='🤚'){
score.loss+=1;console.log('you lose');
updateScoreElement();
document.getElementById('result').innerHTML='You Lose';
}
else{
score.winings+=1;console.log('you win');
updateScoreElement();
document.getElementById('result').innerHTML='You Win';
}
}
else if(user=="✌️"){
if(choice=='✊'){
score.loss+=1;console.log('you lose');
updateScoreElement();
document.getElementById('result').innerHTML='You Lose';
}
else{
score.winings+=1;console.log('you win');
updateScoreElement();
document.getElementById('result').innerHTML='You Win';
}
}

// local storage takes only string so we use JSON object to convert it to string
localStorage.setItem('score',JSON.stringify(score));
}






</script>

</body>
</html>
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,46 @@ This repository also provides one such platforms where contributers come over an

| [Emoji_Intruder](https://github.com/kunjgit/GameZone/tree/main/Games/Emoji_Intruder) | [Guess The Weapon](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_The_Weapon) | [Guess Who](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_Who) | | |
| [Emoji_Intruder](https://github.com/kunjgit/GameZone/tree/main/Games/Emoji_Intruder) | [Guess The Weapon](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_The_Weapon) | [Guess Who](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_Who) | [Pop My Balloon](https://github.com/kunjgit/GameZone/tree/main/Games/Pop_My_Balloon) | |

| [Maze_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Maze_Game) | [Earth_Guardian](https://github.com/kunjgit/GameZone/tree/main/Games/Earth_Guardian) | [Earth_Guardian](https://github.com/kunjgit/GameZone/tree/main/Games/Earth_Guardian) | [HTML5_Controller_Tester](https://github.com/kunjgit/GameZone/tree/main/Games/HTML5_Controller_Tester)

| [escaperoom](https://github.com/kunjgit/GameZone/tree/main/Games/escaperoom)

| [Ball_Shooting_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ball_Shooting_Game) | [HTML5_Controller_Tester](https://github.com/kunjgit/GameZone/tree/main/Games/HTML5_Controller_Tester)

| [numeral-whiz](https://github.com/Ishan-77/GameZone/tree/main/Games/numeral-whiz) | [candy_match](https://github.com/kunjgit/GameZone/tree/main/Games/Candy_Match_Saga) | [Crossy_Road](https://github.com/tanujbordikar/GameZone/tree/Crossy_Road) | [HueHero](https://github.com/kunjgit/GameZone/tree/main/Games/HueHero) | [Puzzel_Winner](https://github.com/kunjgit/GameZone/tree/main/Games/Puzzel_Winner) |
| [Emoji_Intruder](https://github.com/kunjgit/GameZone/tree/main/Games/Emoji_Intruder) | [Guess The Weapon](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_The_Weapon) | [Guess Who](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_Who) | [Pop My Balloon](https://github.com/kunjgit/GameZone/tree/main/Games/Pop_My_Balloon) | [Tower Stack](https://github.com/kunjgit/GameZone/tree/main/Games/Tower_Stack) |
| [Maze_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Maze_Game) | [TriHand_Tactics](https://github.com/kunjgit/GameZone/tree/main/Games/TriHand_Tactics) | [Earth_Guardian](https://github.com/kunjgit/GameZone/tree/main/Games/Earth_Guardian) | [Ball_Shooting_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ball_Shooting_Game) |
| [Ball_Shooting_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ball_Shooting_Game) | [CatchTheBall](https://github.com/kunjgit/GameZone/tree/main/Games/CatchTheBall) |

| [Ball_Shooting_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ball_Shooting_Game) | [DoraemonRun ](https://github.com/kunjgit/GameZone/tree/main/Games/DoraemonRun) |
| [Memory_Cards_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Memory_Cards_Game) |
| [Technical_Mind_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Technical_Mind_Game) |


[Slide_Master_Puzzle](https://github.com/kunjgit/GameZone/tree/Main/Games/Slide_Master_Puzz)| |

| [Ball_Shooting_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ball_Shooting_Game) | [Letter_Sleuth](https://github.com/swetha5157/GameZone/tree/main/Games/Letter_Sleuth)


| [Rock_paper_scissor](https://github.com/kunjgit/GameZone/tree/main/Games/Rock_paper_scissor) |
| [City_Builder_Game](https://github.com/kunjgit/GameZone/tree/main/Games/City_Builder_Game) |

[Mancala_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Mancala_Game) |


| [Dice_Roller](https://github.com/kunjgit/GameZone/tree/main/Games/Dice_Roller) | [Chrome_Dino_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Chrome_Dino_Game) |
| [Rock_paper_scissor](https://github.com/kunjgit/GameZone/tree/main/Games/Rock_paper_scissor) |
| [City_Builder_Game](https://github.com/kunjgit/GameZone/tree/main/Games/City_Builder_Game) |
| [Pokemon_Stats_Card](https://github.com/kunjgit/GameZone/tree/main/Games/Pokemon_Stats_Card) |
| [Steampunk_FlappyBird](https://github.com/kunjgit/GameZone/tree/main/Games/Steampunk_FlappyBird) |

| [Catch_The_Circle](https://github.com/kunjgit/GameZone/tree/main/Games/Catch_The_Circle) |
| [Automated_rock_paper_scissor](https://github.com/kunjgit/GameZone/tree/main/Games/automated_rock_paper_scissor) |

| [Maze_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Maze_Game) | [Astronaut_runner] (https://github.com/tanishkaa08/GameZone/tree/main/Games/Astronaunt_runner) |


| [Dragon_Tower](https://github.com/kunjgit/GameZone/tree/main/Games/Dragon_Tower) |

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