diff --git a/static/js/background_anim.js b/static/js/background_anim.js index 2a6061b28e95d497cf88d4c83aba5ad4adb3a5f2..1d06adfb8623dc9127f65674138246c197515a7f 100644 --- a/static/js/background_anim.js +++ b/static/js/background_anim.js @@ -14,6 +14,9 @@ const DOT_FILL_COLOUR = "#666"; const DOT_OUTLINE_COLOUR = "#444"; const LINE_COLOUR = "#777"; +const VELOCITY_SLOWDOWN_MULTIPLIER = 0.998; +const VELOCITY_PUSH_MULTIPLIER = 1.8; + // ---- // Sort-of constants (change with window size) @@ -211,6 +214,10 @@ const physics = () => { dot.vx = clamp(dot.vx, -VELOCITY_MAX, VELOCITY_MAX); dot.vy = clamp(dot.vy, -VELOCITY_MAX, VELOCITY_MAX); + // Slow down velocity + dot.vx *= VELOCITY_SLOWDOWN_MULTIPLIER; + dot.xy *= VELOCITY_SLOWDOWN_MULTIPLIER; + // Stop velocity from going below initial velocity if(dot.vx < dot.initial_vx) { dot.vx = dot.initial_vx; @@ -222,9 +229,11 @@ const physics = () => { // Invert velocities if off-screen and not already inverted if ((dot.x < 0 && dot.vx < 0) || (dot.x > canvas.width && dot.vx > 0)) { dot.vx = -dot.vx; + dot.vx *= VELOCITY_PUSH_MULTIPLIER; } if ((dot.y < 0 && dot.vy < 0) || (dot.y > canvas.height && dot.vy > 0)) { dot.vy = -dot.vy; + dot.vy *= VELOCITY_PUSH_MULTIPLIER; } // Make dots velocities react to mouse movement (deflected by mouse) @@ -241,6 +250,9 @@ const physics = () => { dot.vx = -dot.vx; dot.vy = -dot.vy; + dot.vx *= VELOCITY_PUSH_MULTIPLIER; + dot.vy *= VELOCITY_PUSH_MULTIPLIER; + dot.x = cx; dot.y = cy; }