Skip to content
Snippets Groups Projects
Verified Commit f101929a authored by TheJoeCoder's avatar TheJoeCoder
Browse files

Fix velocity clamping to initial

parent d6d384ae
Branches
No related tags found
No related merge requests found
......@@ -235,11 +235,19 @@ const physics = () => {
dot.xy *= VELOCITY_SLOWDOWN_MULTIPLIER;
// Stop velocity from going below initial velocity
if(dot.vx < dot.initial_vx) {
if(Math.abs(dot.vx) < Math.abs(dot.initial_vx)) {
if((dot.vx > 0 && dot.initial_vx > 0) || (dot.vx < 0 && dot.initial_vx < 0)) {
dot.vx = dot.initial_vx;
} else {
dot.vx = -dot.initial_vx;
}
if(dot.vy < dot.initial_vy) {
}
if(Math.abs(dot.vy) < Math.abs(dot.initial_vy)) {
if((dot.vy > 0 && dot.initial_vy > 0) || (dot.vy < 0 && dot.initial_vy < 0)) {
dot.vy = dot.initial_vy;
} else {
dot.vy = -dot.initial_vy;
}
}
// Invert velocities if off-screen and not already inverted
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment