Skip to content
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
31 changes: 31 additions & 0 deletions RockPaperScissorsGame/AckermanLevi1/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
body {
font-family: Arial, sans-serif;
text-align: center;
}

h1 {
margin-top: 20px;
}

.choice {
width: 100px;
height: 100px;
cursor: pointer;
margin: 10px;
}

#game {
display: flex;
justify-content: center;
}

#player, #computer {
width: 200px;
}

#result {
margin-top: 20px;
}
#computer {
display: none; /* Initially hidden */
}
28 changes: 28 additions & 0 deletions RockPaperScissorsGame/AckermanLevi1/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rock, Paper, Scissors Game</title>
<link rel="stylesheet" href="./index.css">
</head>
<body>
<h1>Rock, Paper, Scissors Game</h1>
<div id="game">
<div id="player">
<h2>You</h2>
<img src="rock.png" alt="Rock" id="rock" class="choice">
<img src="paper.png" alt="Paper" id="paper" class="choice">
<img src="scissors.png" alt="Scissors" id="scissors" class="choice">
</div>
<div id="computer">
<h2>Computer</h2>
<img src="question.png" alt="Question" id="computer-choice" class="choice">
</div>
<div id="result">
<p>Choose your weapon!</p>
</div>
</div>
<script src="./index.js"></script>
</body>
</html>
36 changes: 36 additions & 0 deletions RockPaperScissorsGame/AckermanLevi1/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const choices = ["rock", "paper", "scissors"];

function getResult(player, computer) {
if (player === computer) return "It's a draw!";
if (
(player === "rock" && computer === "scissors") ||
(player === "scissors" && computer === "paper") ||
(player === "paper" && computer === "rock")
) {
return "You win!";
}
return "Computer wins!";
}

function displayResult(result) {
const resultElement = document.getElementById("result");
resultElement.textContent = result; // Set the result text
}

document.querySelectorAll(".choice").forEach((element) => {
element.addEventListener("click", () => {
const playerChoice = element.id;
const computerChoice = choices[Math.floor(Math.random() * 3)];
const computerChoiceImage = document.getElementById("computer-choice");

// Show the computer's choice element
document.getElementById("computer").style.display = "block";

// Update the computer's choice image
computerChoiceImage.src = `${computerChoice}.png`;

const result = getResult(playerChoice, computerChoice);

displayResult(result);
});
});
Binary file added RockPaperScissorsGame/AckermanLevi1/paper.png
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 RockPaperScissorsGame/AckermanLevi1/rock.png
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 RockPaperScissorsGame/AckermanLevi1/scissors.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.