Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snow effect not paused while window is minimized #689

Closed
LiteralGenie opened this issue Feb 7, 2025 · 3 comments · Fixed by #690
Closed

Snow effect not paused while window is minimized #689

LiteralGenie opened this issue Feb 7, 2025 · 3 comments · Fixed by #690
Labels
bug Something isn't working

Comments

@LiteralGenie
Copy link

LiteralGenie commented Feb 7, 2025

Describe the bug
Snow effect becomes snowstorm when alt-tabbing away and back.

Screenshots

ssr-2025-02-07_16.48.02.mp4

Additional context
vscode seems to pause timers (setInterval(), requestAnimationFrame()) whenever the window is hidden, so updates to pet movement, ball physics, etc are also paused.
However SnowEffect additionally relies on a timeDelta: number to update particle position, so when reopening the window, this delta gets huge and the particles' y-pos goes through the floor. That causes all the particles to respawn at once.

Capping the max delta like ball.ts does to something like 0.1s makes this less noticeable

diff --git a/src/panel/effects/snow.ts b/src/panel/effects/snow.ts
index 2760738..7ef8742 100644
--- a/src/panel/effects/snow.ts
+++ b/src/panel/effects/snow.ts
@@ -67,6 +67,7 @@ export class SnowEffect implements Effect {
 
     startTime: number = 0;
     frameTime: number = 0;
+    maxDelta: number = 0.1;
 
     pAmount: number = 2500; // Snowiness
     pSize: number[] = [0.5, 1.5]; // min and max size
@@ -163,7 +164,7 @@ export class SnowEffect implements Effect {
         }
         // calculate the time since the last frame
         var timeNow = microtime();
-        var timeDelta = timeNow - this.frameTime;
+        var timeDelta = Math.min(timeNow - this.frameTime, this.maxDelta);
 
         for (var i = 0; i < this.particles.length; i++) {
             var particle = this.particles[i];
ssr-2025-02-07_16.49.30.mp4
@LiteralGenie LiteralGenie added the bug Something isn't working label Feb 7, 2025
@tonybaloney
Copy link
Owner

Cool! I enjoyed the unintentional snowstorm effect but this is a better solution. Would you like to submit a PR?

@LiteralGenie
Copy link
Author

PR: #690

But feel free to close it if the snowstorm version is preferred. It just caught my eye since I only use a single monitor and alt-tab a lot.
New winter theme looks great either way!

@tonybaloney
Copy link
Owner

New winter theme looks great either way!

Yeah it does. Kiana Mosser was commissioned to design it especially for this extension. I worked on the snow effects to add a bit more depth. The brief was something like Donkey Kong Country series' snow levels

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants