-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsomehat.js
52 lines (44 loc) · 1.22 KB
/
somehat.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
class Plugin {
async render(div) {
this.img = document.createElement('img');
this.loaded = false;
div.appendChild(this.img);
this.img.addEventListener('load', () => {
this.loaded = true;
div.innerText = 'You have some hat';
});
this.img.src = 'https://raw.githubusercontent.com/tradica/Dark-Forest---Somehat/main/somehat.png';
this.img.style.display = 'none';
div.style.width = '140px';
div.style.height = '140px';
div.innerText = 'loading, please wait!';
console.log(ui.getViewport());
}
draw(ctx) {
if (!this.loaded) return;
const viewport = ui.getViewport();
const planets = ui.getPlanetsInViewport();
for (const p of planets) {
const pixelCenter =
viewport.worldToCanvasCoords(p.location.coords);
const trueRadius = viewport.worldToCanvasDist(
ui.getRadiusOfPlanetLevel(p.planetLevel)
);
ctx.drawImage(
this.img,
0,
0,
958,
980,
pixelCenter.x - (trueRadius * 3),
pixelCenter.y - (trueRadius * 3),
//pixelCenter.x,
//pixelCenter.y,
trueRadius * 6,
trueRadius * 6
);
}
}
destroy() {}
}
plugin.register(new Plugin());