Add limit for angular velocity
This commit is contained in:
@@ -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 |
Reference in New Issue
Block a user