Skip to content

Commit

Permalink
Merge pull request #3961 from meetarora10/but-branch
Browse files Browse the repository at this point in the history
Refresh score button in rock paper scissor game.
  • Loading branch information
kunjgit authored Jun 1, 2024
2 parents bd1f483 + 60eeeb2 commit 20491e5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
6 changes: 6 additions & 0 deletions Games/Rock_paper_scissor/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ <h1>Rock Paper Scissors</h1>
</div>

<div class="board">
<button class="reset" onclick="
userScore=0;
compScore=0;
updateScore(userScore,compScore);
msg.innerText='Play your move';
">Reset score</button>
<p class="p"> Wins </p>
<div class="score-board">
<div class="score">
Expand Down
7 changes: 5 additions & 2 deletions Games/Rock_paper_scissor/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,22 @@ const drawGame = () => {
msg.innerText = "Game was Draw. Play again.";
msg.style.backgroundColor = "#081b31";
};
const updateScore = (userScore,compScore)=>{
userScorePara.innerText = userScore;
compScorePara.innerText = compScore;

}
const showWinner = (userWin, userChoice, compChoice) => {
if (userWin) {
userScore++;
userScorePara.innerText = userScore;
msg.innerText = `You win! Your ${userChoice} beats ${compChoice}`;
msg.style.backgroundColor = "green";
} else {
compScore++;
compScorePara.innerText = compScore;
msg.innerText = `You lost. ${compChoice} beats your ${userChoice}`;
msg.style.backgroundColor = "red";
}
updateScore(userScore,compScore);
};

const playGame = (userChoice) => {
Expand Down
18 changes: 17 additions & 1 deletion Games/Rock_paper_scissor/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@

#user-score,
#comp-score {
font-size: 4rem;
font-size: 3rem;
}

.msg-container {
Expand All @@ -94,4 +94,20 @@
display: inline;
padding: 1rem;
border-radius: 1rem;
}
.reset{
position: relative;
right: 25rem;
top: 11.7rem;
border: 2px solid black;
background: transparent;
border-radius: 6px;
height: 50px;
width: 85px;
font-size: 1rem;
cursor: pointer;
}
.reset:hover{
background-color: black;
color: white;
}
Binary file modified assets/images/Rock_paper_scissor.png
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 20491e5

Please sign in to comment.