-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
185 lines (162 loc) · 6.17 KB
/
index.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
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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="preload" href="https://me.lea.pet/fonts/Roboto-Regular.ttf" as="font" type="font/ttf" crossorigin="anonymous">
<link rel="preload" href="/floofballs/neocat_floof.png" as="image" type="image/png" crossorigin="anonymous">
<link rel="preload" href="/floofballs/neocat_floof__w_.png" as="image" type="image/png" crossorigin="anonymous">
<link rel="preload" href="/floofballs/neocat_floof_happy.png" as="image" type="image/png" crossorigin="anonymous">
<link rel="icon" type="image/png" href="/floofballs/neocat_floof_cute.png">
<title>floofball.dev</title>
<style>
@font-face {
font-family: "Roboto";
src: url("https://me.lea.pet/fonts/Roboto-Regular.ttf");
}
/* Too lazy to remake the actual animation from the game */
@keyframes petted {
0% {
opacity: 0;
}
10% {
opacity: 1;
}
70% {
opacity: 0;
}
}
body {
background-color: #2b2b2b;
color: #a8a8a8;
font-family: "Roboto", monospace;
}
a {
color: #b9b9b9;
text-decoration: none;
}
.outer {
display: flex;
justify-content: center;
align-items: center;
height: 60vh;
}
.footer {
position: absolute;
bottom: 0;
left: 0;
right: 0;
text-align: center;
padding: 16px;
user-select: none;
line-height: 24px;
}
.neocat-petted {
position: fixed;
top: 50%;
left: 0%;
width: 100%;
height: auto;
transform: translateY(-60%);
opacity: 0;
pointer-events: none;
}
.background {
position: fixed;
top: 0;
left: 0;
width: 100%;
object-fit: cover;
z-index: -100000;
filter: blur(30px) brightness(40%);
}
#pet-hint {
transition: opacity 5s;
}
</style>
</head>
<body>
<img src="/neocat_petted.png" class="neocat-petted" id="neocat-petted" />
<img src="/background.jpg" class="background" />
<div class="outer">
<img src="/floofballs/neocat_floof.png" class="neocat" draggable="false" id="neocat" />
</div>
<div class="footer">
<span id="pet-hint">Pet the neocat!</span>
<br />
<a href="https://me.lea.pet">Visit my website</a>
·
<a href="https://github.com/sussycatgirl/floofball.dev" target="_blank">Source Code</a>
·
<a href="https://volpeon.ink/emojis/neocat/" target="_blank">Neocats</a> by Volpeon
·
Background from <a href="https://unsplash.com/photos/white-kitten-Tn8DLxwuDMA" target="_blank">Unsplash</a>
</div>
<script defer data-domain="floofball.dev" data-api="https://stats.lea.pet/api/stats" src="https://stats.lea.pet/js/stats.js"></script>
<script>
const neocat = document.getElementById("neocat");
if (!neocat) {
throw "Neocat broke :(";
}
function setNeocat(expression) {
neocat.src = expression
? `/floofballs/neocat_floof_${expression}.png`
: `/floofballs/neocat_floof.png`;
}
let clicked = false;
let moved = false;
let superHappy = false;
let defaultCat = "";
let neocat_petted = false;
let timeout;
neocat.onpointerdown = () => clicked = true;
neocat.onpointerup = () => {
clicked = false;
if (!moved && !superHappy) {
defaultCat = "_w_";
setNeocat("_w_");
clearTimeout(timeout);
timeout = setTimeout(() => {
defaultCat = "";
setNeocat();
}, 500);
}
}
let prevX = null,
prevY = null,
petted = 0; // Counter for the neocat's expression
total = 0; // Counter for the "neocat petted"
neocat.onpointermove = (e) => {
if (!clicked) return;
moved = true;
const x = e.clientX,
y = e.clientY;
const distX = Math.abs(x - (prevX ?? x)) / neocat.clientWidth * 50;
const distY = Math.abs(x - (prevY ?? y)) / neocat.clientHeight * 50;
prevX = x;
prevY = y;
let distance = Math.sqrt(Math.pow(distX, 2), Math.pow(distY, 2));
petted += distance;
if (petted > 50) {
total += distance;
document.getElementById("pet-hint").style.opacity = 0;
}
if (total > 1000 && !neocat_petted) {
neocat_petted = true;
document.getElementById("neocat-petted").style.animation = "petted 10s";
}
}
setInterval(() => {
petted *= 0.9;
if (petted > 150) {
setNeocat("_w_");
superHappy = true;
}
else if (petted > 50 && !superHappy) setNeocat("happy");
else if (petted < 10) {
setNeocat(defaultCat);
superHappy = false;
}
}, 100);
</script>
</body>
</html>