Skip to content
Open
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
16 changes: 8 additions & 8 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ function getRandomInt() {
const btns = document.querySelectorAll(".options button");
btns.forEach((btn) => {
btn.addEventListener("click", () => {
document.querySelector(".hands .player-hand").src = "rock.png";
document.querySelector(".hands .computer-hand").src = "rock.png";
playerHand.classList.add('shakePlayer')
document.querySelector(".hands .player-hand").src = "../icons/rock-icon.png";
document.querySelector(".hands .computer-hand").src = "../icons/rock-icon.png";
playerHand.classList.add('shakePlayer')
computerHand.classList.add('shakeComputer')
const playerA = btn.querySelector("label").innerText;
const playerB = options[getRandomInt()];
Expand Down Expand Up @@ -87,9 +87,9 @@ function compare(player, computer) {
// computerHand.classList.remove('shake')
}
function update(player, computer) {
const rock = "rock.png";
const paper = "paper.png";
const scissor = "scissor.png";
const rock = "../icons/rock-icon.png";
const paper = "../icons/hand-icon.png";
const scissor = "../icons/scissor-icon.png";

// playerHand
if (player == "rock") {
Expand Down Expand Up @@ -121,8 +121,8 @@ resetBtn.addEventListener("click", () => {
document.querySelector(".score .you").innerText = score.you;
document.querySelector(".score .computer").innerText = score.computer;
document.querySelector(".hands .result").innerText = "";
document.querySelector(".hands .player-hand").src = "rock.png";
document.querySelector(".hands .computer-hand").src = "rock.png";
document.querySelector(".hands .player-hand").src = "../icons/rock-icon.png";
document.querySelector(".hands .computer-hand").src = "../icons/rock-icon.png";
});


Expand Down
46 changes: 24 additions & 22 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,50 +15,52 @@
<body>
<section class="game">
<div class="intro">
<h1>Rock, Paper & Scissors</h1>
</div>

<div class="score">
<h2>
You
<br>
<hr>
Score: <span class="you">0</span>
</h2>
<h2>
Computer
<br>
<hr>
Score: <span class="computer">0</span>
</h2>
<h1></h1>
</div>

<div class="match">
<div class="hands">
<img class="player-hand" src="rock.png" alt="" />
<div class="player-area">
<img class="player-hand" src="../icons/hand-icon.png" alt="" />
</div>
<h2 class="result"></h2>
<img class="computer-hand" src="rock.png" alt="" />
<div class="computer-area">
<img class="computer-hand" src="../icons/hand-icon.png" alt="" />
</div>

</div>

<h2 class="winner">Choose an option</h2>
<div class="options">
<button class="rock">
<img src="./rock.svg" alt="rock"></img>
<img src="../icons/rock-button.png" alt="rock" />
<br>
<label>rock</label>
</button>
<button class="paper">
<img src="./paper.svg" alt="paper"></img>
<img src="../icons/hand-button.png" alt="paper" />
<br>
<label>paper</label>
</button>
<button class="scissor">
<img src="./scissor.svg" alt="scissor"></img>
<img src="../icons/scissor-button.png" alt="scissor" />
<br>
<label>scissor</label>
</button>
</div>
</div>

<div class="score">
<div class="score-block">
<h2>You</h2>
<hr>
<h2>Score: <span class="you">0</span></h2>
</div>
<div class="score-block">
<h2>Computer</h2>
<hr>
<h2>Score: <span class="computer">0</span></h2>
</div>
</div>

<!----- Reset Button ----->
<div class="reset-div">
Expand Down
Binary file removed paper.png
Binary file not shown.
3 changes: 0 additions & 3 deletions paper.svg

This file was deleted.

Binary file removed rock.png
Binary file not shown.
3 changes: 0 additions & 3 deletions rock.svg

This file was deleted.

Binary file removed scissor.png
Binary file not shown.
3 changes: 0 additions & 3 deletions scissor.svg

This file was deleted.

73 changes: 49 additions & 24 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@
100% { transform: translateY(0) }
}

html,
html {
box-sizing: border-box;
}
body {
padding: 0;
margin: 0;
width: 100%;
overflow-x: hidden;
background: #0f0f0f;
color: #fff;
width: 100vw;
height: 100vh;
overflow: hidden;
background: url('../icons/background.png') center center/cover no-repeat;
color: #222;
font-family: "Open Sans", sans-serif;
}

Expand Down Expand Up @@ -51,6 +54,11 @@ section {
}

.reset-div{
position: absolute;
left: 50%;
bottom: 20px;
transform: translateX(-50%);
width: 100vw;
text-align: center;
}
/*--------------------*/
Expand All @@ -72,14 +80,23 @@ section {
}

.score h2{
font-weight: 400;
font-weight: bold;
color: #fff;
font-family: Monaco, monospace;
}

.score hr{
margin-top: 25px;
margin-bottom: 25px;
}

.score-block {
background: #222;
border-radius: 18px;
padding: 18px 28px;
display: inline-block;
box-shadow: 0 2px 8px #222;
}
.winner{
font-weight: 400;
}
Expand All @@ -94,17 +111,17 @@ section {
@media screen and (max-width:725px) {

}
.match {
.hands {
position: absolute;
top: 50%;
left: 0;
width: 50vw;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
justify-content: space-between;
margin-top: -2rem;
}

.match h2 {
font-size: 2rem;
text-align: center;
gap: 15vw;
transform: translateY(-50%);
pointer-events: none;
}

.match .hands {
Expand All @@ -124,11 +141,15 @@ section {
}

.options {
min-height: 130px;
position: absolute;
left: 50%;
bottom: 100px;
transform: translateX(-50%);
min-height: 120px;
display: flex;
align-items: flex-start;
gap: 1.5rem;
margin: 0 auto;
align-items: flex-end;
gap: 0.5rem;
margin: 0;
justify-content: center;
}

Expand All @@ -152,13 +173,15 @@ section {
margin-top: 25px;
display: inline-block;
opacity: 1;
color: #000;
}

.options button img{
height: 50px;
height: 130px;
width: 130px;
}

.options .paper img{
.options .hand img{
width: 50px;
height: auto;
}
Expand Down Expand Up @@ -193,9 +216,11 @@ section {
.hands{
gap: 1rem;
}
.player-hand,
.computer-hand{
width: 170px;
.user-symbol {
margin-left: -5vw; /* Moves the user hand left */
}
.computer-symbol {
margin-right: 0; /* Adjusts the computer hand */
}
h2.result{
font-size: 1.2rem;
Expand Down