-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchicken.html
110 lines (89 loc) · 3.13 KB
/
chicken.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chicken</title>
<style>
body {
margin: 0;
padding: 0;
}
canvas {
display: block;
margin: auto;
border: 0px;
background: repeating-linear-gradient(-90deg, red 0%, yellow 7.14%, lime, 21.4%, cyan 28.56%, blue 35.7%, magenta 42.84%, red 50%);
background-size: 100vw 100vw;
animation: slide 1s linear infinite;
}
@keyframes slide {
from {
background-position-x: 0vw;
}
to {
background-position-x: 100vw;
}
}
.bgm {
position: absolute;
left: 10px;
top: 10px;
}
</style>
</head>
<body>
<canvas id="myCanvas" width="400" height="400"></canvas>
<img id="sentry" src="sentry.webp" width="300" height="300" hidden>
<img id="chicken" src="chicken.webp" width="50" height="50" hidden>
<script>
const canvas = document.getElementById('myCanvas');
const ctx = canvas.getContext('2d');
const sentry = document.getElementById("sentry");
const chicken = document.getElementById("chicken");
let cOffset = 0;
let hintNeeded = true;
setInterval(draw, 1000 / 60);
function drawRotatedImage(image, x, y, angle) {
var width = image.width;
var height = image.height;
ctx.translate(x, y);
ctx.rotate(angle);
ctx.drawImage(image, -width / 2, -height / 2, width, height);
ctx.rotate(-angle);
ctx.translate(-x, -y);
}
function draw() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
const inc = canvas.width / 300;
var x = canvas.width / 2 + Math.sin(cOffset / 40) * 30;
var y = canvas.height / 2;
var angle = Math.sin(cOffset / 40) / 4;
drawRotatedImage(sentry, x, y, angle);
x = canvas.width / 2 - 150;
y = canvas.height / 2 + Math.sin(cOffset / 40) * 30;
angle = 90 / 180 * 3.14;
drawRotatedImage(chicken, x, y, angle);
x = canvas.width / 2 + 150;
y = canvas.height / 2 - Math.sin(cOffset / 40) * 30;
angle = 90 / 180 * 3.14;
drawRotatedImage(chicken, x, y, angle);
sentry.x = canvas.width / 2;
sentry.y = canvas.height / 2;
if (hintNeeded) {
ctx.font = "48px serif";
ctx.fillText("TURN ON MUSIC", 350, 50);
}
cOffset += 5;
}
function hideHint() {
hintNeeded = false;
var bgm = document.getElementById("bgm");
bgm.controls = false;
}
</script>
<audio id="bgm" class="bgm" preload="auto" autoplay src="bgm.ogg" controls onplay="hideHint();" loop></audio>
Music: Zalza - The Original 2204355 Chicken Man Song
</body>
</html>