-
Notifications
You must be signed in to change notification settings - Fork 0
/
punch_bill_gates.html
76 lines (63 loc) · 2.9 KB
/
punch_bill_gates.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
65
66
67
68
69
70
71
72
73
74
75
76
<html>
<head>
<style>
html, body {
overflow: hidden;
}
body {
background-image: url("https://www.stackumbrella.com/wp-content/uploads/2021/05/imgpsh_fullsize_anim-2-6.jpg");
background-repeat: no-repeat;
background-size: cover;
}
#punch, #money, #windows {
display: none;
}
</style>
<title>Punch Bill Gate$</title>
</head>
<body>
<img id="punch" src="https://www.transparentpng.com/thumb/punch/5P5pK1-punch-free-download.png">
<img id="money" src="https://i2.wp.com/sitesovety.ru/wp-content/uploads/2011/10/100-%D0%B4%D0%BE%D0%BB%D0%BB%D0%B0%D1%80%D0%BE%D0%B2-%D0%A1%D0%A8%D0%90.jpeg">
<img id="windows" src="https://clipartmag.com/images/windows-7-cliparts-17.png">
<canvas id="canvas"></canvas>
<script>
const punchImage = document.getElementById("punch");
const punchAudio = new Audio("https://www.sfxbuzz.com/jdownloads/Free%20Fight%20Sounds%20Sound%20Effects/PUNCH.mp3");
const moneyImage = document.getElementById("money");
const moneyAudio = new Audio("https://freesound.org/data/previews/554/554841_12425847-lq.mp3");
const windowsImage = document.getElementById("windows");
const windowsAudio = new Audio("https://www.myinstants.com/media/sounds/erro.mp3")
const myCanvas = document.getElementById("canvas");
const context = myCanvas.getContext("2d");
myCanvas.width = window.innerWidth;
myCanvas.height = window.innerHeight;
const body = document.body;
function random(limit) {
return Math.floor(Math.random() * limit) + 1;
}
function punch(x, y) {
context.clearRect(0, 0, myCanvas.width, myCanvas.height);
context.drawImage(punchImage, x - 200, y - 200);
if (Math.random() > 0.95) {
context.drawImage(moneyImage, random(myCanvas.width), random(myCanvas.height));
moneyAudio.play()
}
if (Math.random() < 0.05) {
context.drawImage(windowsImage, random(myCanvas.width), random(myCanvas.height));
windowsAudio.play()
}
if (punchAudio.paused) {
punchAudio.play();
} else {
punchAudio.pause();
punchAudio.currentTime = 0;
punchAudio.play();
}
}
body.addEventListener('click',(event) => {
console.log(event.clientX);
punch(event.clientX, event.clientY);
});
</script>
</body>
</html>