Rock Paper Scissors Game
Rock Paper Scissors Game
HTML Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Rock Paper Scissors</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="game-container">
<h1>Rock Paper Scissors</h1>
<div class="choices">
<button onclick="play('rock')">Rock</button>
<button onclick="play('paper')">Paper</button>
<button onclick="play('scissors')">Scissors</button>
</div>
<div class="result">
<p id="player-choice">You chose: </p>
<p id="computer-choice">Computer chose: </p>
<p id="winner">Result: </p>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
CSS Code
body {
font-family: Arial, sans-serif;
background: #f0f8ff;
text-align: center;
padding: 50px;
}
.game-container {
background: white;
border-radius: 12px;
padding: 30px;
max-width: 400px;
margin: auto;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.choices button {
padding: 10px 20px;
margin: 10px;
font-size: 16px;
cursor: pointer;
border: none;
Rock Paper Scissors Game Project
border-radius: 6px;
background: #007BFF;
color: white;
transition: 0.3s;
}
.choices button:hover {
background: #0056b3;
}
.result p {
font-size: 18px;
margin-top: 10px;
}
JavaScript Code
function play(playerChoice) {
const choices = ['rock', 'paper', 'scissors'];
const computerChoice = choices[Math.floor(Math.random() * 3)];