From 5fdfc770565d0bdc63c22ea43151afbbe4dbaf1d Mon Sep 17 00:00:00 2001 From: top Date: Thu, 12 Oct 2023 13:13:41 +0000 Subject: [PATCH] top/slightly-improve-stalker-performance (#213) Tbh thought this would have more of an impact but only improves performance of the animation about 25%. Apparently stalker isn't actually that big of an issue. Either way it saves on css recalculations and repaints. Also update blackjack to show the correct visual state for the dealer Co-authored-by: Chuck Reviewed-on: https://fsdfsd.net/rDrama/rDrama/pulls/213 Co-authored-by: top Co-committed-by: top --- files/assets/events/homoween/css/stalker.css | 2 ++ files/assets/events/homoween/js/stalker.js | 12 ++++++------ files/assets/js/casino/blackjack_screen.js | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/files/assets/events/homoween/css/stalker.css b/files/assets/events/homoween/css/stalker.css index 9526cb1a3..31d4eb885 100644 --- a/files/assets/events/homoween/css/stalker.css +++ b/files/assets/events/homoween/css/stalker.css @@ -2,6 +2,8 @@ img.cursor-stalker { position: absolute; height: 28px; width: 28px; + top: 0; + left: 0; background-repeat: no-repeat; background-size: 100% auto; z-index: 1000000000; diff --git a/files/assets/events/homoween/js/stalker.js b/files/assets/events/homoween/js/stalker.js index 895a0c481..05d73ea00 100644 --- a/files/assets/events/homoween/js/stalker.js +++ b/files/assets/events/homoween/js/stalker.js @@ -64,8 +64,9 @@ function stalker(i) { function placestalker(stalker, x, y) { stalker.x = x; stalker.y = y; - stalker.img.style.left = stalker.x + "px"; - stalker.img.style.top = stalker.y + "px"; + const left = stalker.x + "px"; + const top = stalker.y + "px"; + stalker.img.style.transform = `translate(${left}, ${top})` } function makeCircle() { @@ -73,10 +74,9 @@ function makeCircle() { current -= rotation; for (let i = count - 1; i > -1; --i) { stalker = stalkers[i]; - stalker.img.style.top = - Math.round(stalker.y + a * Math.sin((current + i) / spacing) - 15) + "px"; - stalker.img.style.left = - Math.round(stalker.x + a * Math.cos((current + i) / spacing)) + "px"; + const top = Math.round(stalker.y + a * Math.sin((current + i) / spacing) - 15) + "px"; + const left = Math.round(stalker.x + a * Math.cos((current + i) / spacing)) + "px"; + stalker.img.style.transform = `translate(${left}, ${top})` } } diff --git a/files/assets/js/casino/blackjack_screen.js b/files/assets/js/casino/blackjack_screen.js index 213989e9d..ca2ecfe72 100644 --- a/files/assets/js/casino/blackjack_screen.js +++ b/files/assets/js/casino/blackjack_screen.js @@ -185,7 +185,7 @@ function updateCardsetBackgrounds(state, complete = false) { } if(complete){ const wager = state.has_player_split ? state?.wager?.amount * 2 : state?.wager?.amount; - let dealerShows = state.payout > wager ? 'WON': 'LOST'; + let dealerShows = state.payout < wager ? 'WON': 'LOST'; if(state.payout === wager) dealerShows = 'PUSHED' cardsets[0]?.classList.add(`blackjack-cardset__${dealerShows}`) }