From dd80e984eb5394c2649cdf50bdb93f91064c7e65 Mon Sep 17 00:00:00 2001 From: Aevann Date: Wed, 11 Oct 2023 18:14:58 +0300 Subject: [PATCH] add stalker award --- files/assets/css/main.css | 1 + files/assets/events/homoween/css/stalker.css | 13 +++ files/assets/events/homoween/js/stalker.js | 112 +++++++++++++++++++ files/helpers/config/awards.py | 13 +++ files/templates/events/homoween/awards.html | 6 + 5 files changed, 145 insertions(+) create mode 100644 files/assets/events/homoween/css/stalker.css create mode 100644 files/assets/events/homoween/js/stalker.js diff --git a/files/assets/css/main.css b/files/assets/css/main.css index c27e8a712..027d1204d 100644 --- a/files/assets/css/main.css +++ b/files/assets/css/main.css @@ -216,6 +216,7 @@ .fa-tv:before{content:"\f26c"} .fa-heart:before{content:"\f004"} .fa-coin:before{content:"\f85c"} +.fa-scarecrow:before{content:"\f70d"} /* do not remove - fixes hand, talking, marsey-love components from breaking out of the comment box diff --git a/files/assets/events/homoween/css/stalker.css b/files/assets/events/homoween/css/stalker.css new file mode 100644 index 000000000..4c5f5ba2b --- /dev/null +++ b/files/assets/events/homoween/css/stalker.css @@ -0,0 +1,13 @@ +body { + background: #000; + height: 100vh; + width: 100vw; +} + +img.cursor-ghost { + position: absolute; + height: 28px; + width: 28px; + background-repeat: no-repeat; + background-size: 100% auto; +} diff --git a/files/assets/events/homoween/js/stalker.js b/files/assets/events/homoween/js/stalker.js new file mode 100644 index 000000000..1d1104a8f --- /dev/null +++ b/files/assets/events/homoween/js/stalker.js @@ -0,0 +1,112 @@ +const assets = [ + "marseyjason", + "marseynightmare", + "marseyhellraiser", + "marseysaw", + "marseyzombie2", + "marseywerewolf", + "marseysatangoat", + "marseyskeleton2", + "marseystabby", + "marseyface", + "marseydaemon", + "marseygrimreaper", + "marseycheshire4", + "marseyaugust", + "marseycerebrus", + "marseyzombie", + "marseything", + "marseytwins", + "marseymonstrosity", + "marseykrampus", + "marseybaphomet", + "marseyfacepeel", + "carpwitchtrans", + "capymummy", + "marseynotesbardfinn" +]; + +const count = document.getElementById('stalker-count').value, + size = 25, + spacing = 4 - 0.05 * count, + diameter = 20 + 0.5 * count, + rotation = 0.04 + 0.001 * count, + speed = 0.03 + 0.002 * count, + offset = 10; + +let ghosts = [], + a = Math.round(size * diameter * 0.2), + current = offset, + mouse = { + x: a + offset, + y: a + offset + }; + +// populate ghosts +for (let i = 0; i < count; i++) { + ghosts[i] = new ghost(i); +} + +function ghost(i) { + this.x = 0; + this.y = 0; + this.X = 0; + this.Y = 0; + this.img = document.createElement("img"); + this.img.id = "ghost-" + i; + this.img.className = "cursor-ghost"; + this.img.src = `${SITE_FULL_IMAGES}/e/${assets[i]}.webp`; + document.body.appendChild(this.img); +} + +function placeghost(ghost, x, y) { + ghost.x = x; + ghost.y = y; + ghost.img.style.left = ghost.x + "px"; + ghost.img.style.top = ghost.y + "px"; +} + +function makeCircle() { + let ghost; + current -= rotation; + for (let i = count - 1; i > -1; --i) { + ghost = ghosts[i]; + ghost.img.style.top = + Math.round(ghost.y + a * Math.sin((current + i) / spacing) - 15) + "px"; + ghost.img.style.left = + Math.round(ghost.x + a * Math.cos((current + i) / spacing)) + "px"; + } +} + +addEventListener("mousemove", function (e) { + mouse.x = e.pageX; + mouse.y = e.pageY; +}); + +addEventListener("touchstart", function (e) { + event.preventDefault(); // we don't want to scroll + let touch = event.touches[0]; + mouse.x = touch.clientX; + mouse.y = touch.clientY; +}); + +function getRandom(min, max) { + return Math.floor(Math.random() * (max - min + 1) + min); +} + +function draw() { + let ghost = ghosts[0]; + let prevghost = ghosts[0]; + ghost.x = ghost.X += (mouse.x - ghost.X) * speed; + ghost.y = ghost.Y += (mouse.y - ghost.Y) * speed; + for (let i = count - 1; i > 0; --i) { + ghost = ghosts[i]; + prevghost = ghosts[i - 1]; + ghost.x = ghost.X += (prevghost.x - ghost.X) * speed; + ghost.y = ghost.Y += (prevghost.y - ghost.Y) * speed; + } + makeCircle(); + requestAnimationFrame(draw); +} + +draw(); diff --git a/files/helpers/config/awards.py b/files/helpers/config/awards.py index 36b757481..248b0217d 100644 --- a/files/helpers/config/awards.py +++ b/files/helpers/config/awards.py @@ -237,6 +237,19 @@ AWARDS = { "enabled": IS_HOMOWEEN(), "positive": True, }, + "stalker": { + "kind": "stalker", + "title": "Stalker", + "description": "???", + "icon": "fas fa-scarecrow", + "color": "text-primary", + "price": 250, + "deflectable": False, + "cosmetic": True, + "ghost": True, + "enabled": IS_HOMOWEEN(), + "positive": True, + }, "candy-corn": { "kind": "candy-corn", "title": "Candy Corn", diff --git a/files/templates/events/homoween/awards.html b/files/templates/events/homoween/awards.html index f87224cfb..34876b4d4 100644 --- a/files/templates/events/homoween/awards.html +++ b/files/templates/events/homoween/awards.html @@ -56,3 +56,9 @@ {% endif %} + +{% if p.award_count("stalker", v) %} + + + +{% endif %}