Add limit for angular velocity

This commit is contained in:
2026-01-17 15:23:59 -08:00
parent d779f802a6
commit 616c8184d0

View File

@@ -813,10 +813,13 @@ function updateShip(s, elapsed) {
s.angularVelocity = angularVel + angularAcc;
const friction = 0.05;
const limit = 3;
if (s.angularVelocity > 0) {
if (s.angularVelocity > limit) s.angularVelocity = limit;
s.angularVelocity -= s.angularVelocity > friction ? friction : s.angularVelocity;
} else if (s.angularVelocity < 0) {
if (s.angularVelocity < -limit) s.angularVelocity = -limit;
s.angularVelocity += -s.angularVelocity > friction ? friction : -s.angularVelocity;
}
@@ -845,7 +848,7 @@ function updateShip(s, elapsed) {
// s.collision = detectCollision([px, py], p, s.velocity, tempRadius, map);
s.collision = detectCollision([px, py], p, s.velocity, s.radius, map, s.gearDown);
if (s.collision) console.log("COLLISION", s.collision);
if (!current && s.collision) console.log("COLLISION", s.collision);
legs.style.display = s.gearDown ? "initial" : "none";

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB