-
Notifications
You must be signed in to change notification settings - Fork 27
/
darkplace.js
179 lines (172 loc) · 5.54 KB
/
darkplace.js
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
/* eslint-disable jsdoc/require-jsdoc */
// Special features for april fools darkplace event
let fallingMessages = null
let fallingMessageInterval = -1
let backgroundCanvas = null
async function enableDarkplace() {
const forceTheme = "r/place 2022"
const forceVariant = "dark"
forceTheme(forceTheme, forceVariant)
const bgWrapper = document.getElementById("bgWrapper")
backgroundCanvas = document.getElementById("backgroundCanvas") || document.createElement("canvas")
backgroundCanvas.id = "backgroundCanvas"
backgroundCanvas.style.position = "absolute"
backgroundCanvas.style.top = "0"
backgroundCanvas.style.left = "0"
backgroundCanvas.style.width = "100%"
backgroundCanvas.style.height = "100%"
backgroundCanvas.style.filter = "blur(1px)"
bgWrapper?.appendChild(backgroundCanvas)
function updateBgCanvasSize() {
backgroundCanvas.width = window.innerWidth
backgroundCanvas.height = window.innerHeight
}
updateBgCanvasSize()
window.addEventListener("resize", updateBgCanvasSize)
const messages = [
"88",
"Zekiah",
"X!Gaster",
"Zubigri",
"Lazvell.09",
"Thiagoxnahuel",
"Ward",
"Bushi",
"Lapis",
"Relick",
"BlobKat",
"BeyazVoid",
"Ysufxad",
"Redje",
"Etta",
"BiskivitliTost",
"MTC",
"TmusiniYan",
"SUS",
"Люти Омни",
"Авир",
"Ых",
"Insertnamehere",
"Mr. John",
"Царь изумрудного королевства",
"The Great Wall",
"C42Ё!!!",
"Forbidding racism is racist",
"Bugfix when? No",
"Later, never",
"∆∆∆",
"∆ ∆∆",
"Zubigri write this text",
"Geometry Dash",
"TK",
"BCS",
"rplace.live",
"not rplace.tk",
"darkplace.live",
"susplace.live",
"is am are what???",
"r/place 2 ad it",
"The Bullet? The Bullet!",
"BloodBath",
"Legalise nuclear bombs",
"Absence of proof is not proof of absence",
"Proof of absence is not absence of proof",
"Qwertyuiop",
"Asdfghjkl",
"Zxcvbnm",
"Site is saled",
"(Nothing)",
"Loading...)",
"...---...",
"Code",
"Decode",
"Delete :vip? Too lazy",
"АРМОРС!!!",
"КОНЬ НИЗКО ЛЕТИТ К ДОЖДЮ, НЕГРОВАЯ КРАСКА СЛЕЗЛА С ФЕРЗЯ И ОН ОТБЕЛИЛСЯ!!!",
"Make Flag Speedrun Here",
"3301",
"42",
"666",
"777",
"13",
"284654548244662065667669143349975505484487365510612937903489695250411210311237163400731822443778191321442634040459295815516156858468105775285314299961880757005305548204686781529063932731323704485670912",
"Ñ",
"196883 Dimensions?",
"Peace is never was an opinion",
"Loading screen text",
"Zek add loading screen text — ©Zubigri",
"blobk.at 19132 mc server join",
"We eat pixels",
"The End.",
"爱国无罪",
"富狗",
"我是好黑",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"❤️ ataturk"
]
let wind = 1
const gravity = 0.001
const messageColours = ["#fff", "#aaa", "#db7c7c", "#4a4949"]
class FallingMessage {
constructor(x, y, msg) {
this.x = x
this.y = y
this.msg = msg
this.colour = messageColours[Math.floor(Math.random() * messageColours.length)]
this.fontSize = Math.random() * 32 + 6
this.velocityY = Math.random() * 0.4
this.velocityX = Math.random() - 0.5
}
update(ctx) {
this.velocityX += wind * (38 / this.fontSize) * 0.014
this.x += this.velocityX
this.velocityY += gravity
this.y += this.velocityY
const speed = Math.abs(this.velocityX * this.velocityY)
ctx.globalAlpha = Math.min(1, speed * 0.4 + 0.4)
ctx.font = `${this.fontSize}px 'Brush Script MT', cursive`
ctx.fillStyle = this.colour
ctx.fillText(this.msg, this.x, this.y)
}
}
const backgroundContext = backgroundCanvas.getContext("2d")
if (backgroundContext == null) {
return
}
fallingMessages = new Set()
let lastWindChange = Date.now()
let lastSpawn = Date.now()
clearInterval(fallingMessageInterval)
fallingMessageInterval = setInterval(() => {
backgroundContext.clearRect(0, 0, window.innerWidth, window.innerHeight)
if (Date.now() - lastSpawn > 400 && Math.random() < 0.1) {
const chosenMessage = messages[Math.floor(Math.random() * messages.length)]
fallingMessages.add(new FallingMessage(Math.random() * window.innerWidth - 100, 0, chosenMessage))
lastSpawn = Date.now()
}
if (Date.now() - lastWindChange > 5_000 && Math.random() < 0.3) {
wind = Math.random() * 0.1 - 0.05
lastWindChange = Date.now()
}
for (const message of fallingMessages) {
message.update(backgroundContext)
if (message.y > window.innerHeight) {
fallingMessages.delete(message)
}
}
}, 17)
}
function disableDarkplace() {
fallingMessages?.clear()
clearInterval(fallingMessageInterval)
backgroundCanvas?.remove()
}