diff --git a/RockPaperScissorsGame/AckermanLevi1/index.css b/RockPaperScissorsGame/AckermanLevi1/index.css new file mode 100644 index 000000000..e610a62a4 --- /dev/null +++ b/RockPaperScissorsGame/AckermanLevi1/index.css @@ -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 */ +} \ No newline at end of file diff --git a/RockPaperScissorsGame/AckermanLevi1/index.html b/RockPaperScissorsGame/AckermanLevi1/index.html new file mode 100644 index 000000000..4eef4ac39 --- /dev/null +++ b/RockPaperScissorsGame/AckermanLevi1/index.html @@ -0,0 +1,28 @@ + + + + + + Rock, Paper, Scissors Game + + + +

Rock, Paper, Scissors Game

+
+
+

You

+ Rock + Paper + Scissors +
+
+

Computer

+ Question +
+
+

Choose your weapon!

+
+
+ + + diff --git a/RockPaperScissorsGame/AckermanLevi1/index.js b/RockPaperScissorsGame/AckermanLevi1/index.js new file mode 100644 index 000000000..953e64db0 --- /dev/null +++ b/RockPaperScissorsGame/AckermanLevi1/index.js @@ -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); + }); +}); diff --git a/RockPaperScissorsGame/AckermanLevi1/paper.png b/RockPaperScissorsGame/AckermanLevi1/paper.png new file mode 100644 index 000000000..6f6f60315 Binary files /dev/null and b/RockPaperScissorsGame/AckermanLevi1/paper.png differ diff --git a/RockPaperScissorsGame/AckermanLevi1/rock.png b/RockPaperScissorsGame/AckermanLevi1/rock.png new file mode 100644 index 000000000..6278c08d7 Binary files /dev/null and b/RockPaperScissorsGame/AckermanLevi1/rock.png differ diff --git a/RockPaperScissorsGame/AckermanLevi1/scissors.png b/RockPaperScissorsGame/AckermanLevi1/scissors.png new file mode 100644 index 000000000..c53b9d9c6 Binary files /dev/null and b/RockPaperScissorsGame/AckermanLevi1/scissors.png differ