-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwinstonrockpaper.html
64 lines (59 loc) · 2.21 KB
/
winstonrockpaper.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.pencet{
width:300px;
height:300px;
}
</style>
</head>
<body>
<h1>Hello, This is my Rock Paper Scissor Game ! Click on one to play !</h1>
<button onclick="generate_number(1)" id="rock"><img src=rps/rock.jpg class="pencet"></button>
<button id="paper" onclick="generate_number(2)"><img src=rps/paper.jfif class="pencet"></button>
<button id="scissor" onclick="generate_number(3)"><img src=rps/scissor.jfif class="pencet"></button>
<h1 id="choice"></h1>
<h1 id="result"></h1>
</body>
<script>
function generate_number(choice){
let computer = Math.floor((Math.random() * 3) + 1);
const choic = document.querySelector("#choice");
const result = document.querySelector("#result");
const rock = document.querySelector("#rock");
const scissor = document.querySelector("#scissor");
const paper = document.querySelector("#paper");
if(computer == 1){
choic.textContent = "The Computer chose Rock !";
}
else if(computer == 2){
choic.textContent = "The Computer Chose Paper !";
}
else{
choic.textContent = "The Computer Chose Scissor !";
}
function delayed_alert(kata,time){
return setTimeout(()=>alert(kata),time);
}
if(choice == computer){
result.textContent = "It's a Draw -_-";
}
else if(choice == 1 && computer == 3 || choice == 2 && computer == 1|| choice == 3 && computer == 2){
result.textContent = "YOU HAVE WON ^_^!!!";
confetti.start(5000,1000);
paper.disabled = true;
scissor.disabled = true;
rock.disabled = true;
setTimeout(()=>{paper.disabled = false; scissor.disabled = false; rock.disabled= false;},4500);
}
else{
result.textContent = "YOU LOST >_< !";
}
}
</script>
<script src="https://cdn.jsdelivr.net/gh/mathusummut/confetti.js/confetti.min.js"></script>\
</html>