-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRock_Paper_Scissors
More file actions
205 lines (201 loc) · 6.71 KB
/
Copy pathRock_Paper_Scissors
File metadata and controls
205 lines (201 loc) · 6.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Rock Paper Scissors</title>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
margin: 0;
display: flex;
flex-direction: column;
align-items: center;
background-color: black;
position: relative;
background-image: url("rock_back_3.jpg");
background-size: cover;
background-repeat: no-repeat;
background-attachment: fixed;
min-height: 100vh;
background-position: 35% 50%;
}
.choices {
margin-bottom: 30px;
}
.choices button {
font-size: 8rem;
width: 160px;
margin: 1cm 10px;
border-radius: 250px;
border-color: purple;
border-width: 5px;
background-color: hsl(200, 100%, 50%);
cursor: pointer;
transition: background-color 0.5s ease;
}
.choices button:hover {
background-color: aquamarine;
transform: scale(1.1);
}
#chumma {
font-size: 5rem;
margin: 20px 0;
color: black;
padding: 10px;
background-color: #f9f9f9;
box-shadow: 2px 2px 12px rgba(0, 0, 0, 0.3);
width: 60%;
}
#player_display,
#computer_display,
#chumma {
font-size: 2rem;
background-color: #ce0000;
color: white;
padding: 10px 20px;
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.2);
width: 350px;
margin: 10px 0;
text-align: center;
}
.score_board {
margin-top: 10px;
display: grid;
grid-template-columns: 1fr 1fr;
width: 350px;
height: auto;
font-family: Georgia, "Times New Roman", Times, serif;
background-color: #ce0000;
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
color: whitesmoke;
/* border-radius: 15px; */
padding: 20px;
}
.score_name,
.score {
padding: 10px;
text-align: center;
}
.score_name {
font-weight: bold;
padding: 10px 0;
}
.score {
background-color: white;
/* border-radius: 8px; */
color: black;
font-family: "Seven Segment", sans-serif;
font-weight: bold;
font-size: 50px;
justify-content: center;
display: flex;
justify-content: space-around;
align-items: center;
margin: 0 10px;
}
#score_name_1 {
color: whitesmoke;
font-size: larger;
}
#score_name_2 {
color: whitesmoke;
font-size: larger;
}
.display_section {
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 30px;
}
.audio-control {
font-size: 2rem;
padding: 10px;
position: absolute;
top: 10px;
left: 10px;
width: auto;
border-radius: 5px;
background-color: rgb(110, 231, 11);
border-color: black;
cursor: pointer;
}
.audio-control:hover {
transform: scale(1.1);
}
</style>
</head>
<body>
<audio id="backgroundMusic" src="Solaiyamma _Raasa_Ilayaraasa.mp3">
Your browser does not support the audio element.
</audio>
<button class="audio-control" onclick="play_audio()">PLAY MUSIC</button>
<div class="score_board">
<div class="score_name" id="score_name_1">PLAYER</div>
<div class="score_name" id="score_name_2">COMPUTER</div>
<div class="score" id="play_score">0</div>
<div class="score" id="comp_score">0</div>
</div>
<div class="choices">
<button onclick="play_game('rock')">👊</button>
<button onclick="play_game('paper')">🤚</button>
<button onclick="play_game('scissors')">✌️</button>
</div>
<section class="display_section">
<div id="player_display">PLAYER :</div>
<div id="computer_display">COMPUTER :</div>
<h1 id="chumma"></h1>
</section>
<script>
const choices = ["rock", "paper", "scissors"];
const player_display = document.getElementById("player_display");
const computer_display = document.getElementById("computer_display");
const result_display = document.getElementById("result_display");
var player_score = 0;
var computer_score = 0;
function play_game(player_choice) {
const computer_choice = choices[Math.floor(Math.random() * 3)];
player_display.textContent = `PLAYER: ${player_choice.toUpperCase()}`;
computer_display.textContent = `COMPUTER: ${computer_choice.toUpperCase()}`;
if (player_choice == computer_choice) {
document.getElementById("chumma").innerHTML = "IT IS A TIE";
} else if (player_choice == "rock" && computer_choice == "scissors") {
player_score++;
document.getElementById("chumma").innerHTML = "PLAYER WINS";
document.getElementById("play_score").innerHTML = player_score;
} else if (player_choice == "scissors" && computer_choice == "rock") {
computer_score++;
document.getElementById("chumma").innerHTML = "COMPUTER WINS";
document.getElementById("comp_score").innerHTML = computer_score;
} else if (player_choice == "rock" && computer_choice == "paper") {
computer_score++;
document.getElementById("chumma").innerHTML = "COMPUTER WINS";
document.getElementById("comp_score").innerHTML = computer_score;
} else if (player_choice == "paper" && computer_choice == "rock") {
player_score++;
document.getElementById("chumma").innerHTML = "PLAYER WINS";
document.getElementById("play_score").innerHTML = player_score;
} else if (player_choice == "scissors" && computer_choice == "paper") {
player_score++;
document.getElementById("chumma").innerHTML = "PLAYER WINS";
document.getElementById("play_score").innerHTML = player_score;
} else if (player_choice == "paper" && computer_choice == "scissors") {
computer_score++;
document.getElementById("chumma").innerHTML = "COMPUTER WINS";
document.getElementById("comp_score").innerHTML = computer_score;
}
}
const audio = document.getElementById("backgroundMusic");
const audioButton = document.querySelector(".audio-control");
function play_audio() {
if (audio.paused) {
audio.play();
audioButton.textContent = "Pause Music";
} else {
audio.pause();
audioButton.textContent = "Play Music";
}
}
</script>
</body>
</html>