From ad86535ca1128949870325ab6c391891c83ff906 Mon Sep 17 00:00:00 2001 From: Josh Deprez Date: Thu, 12 Aug 2021 16:23:52 +1000 Subject: [PATCH] more physics tweaks --- game/aw.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/game/aw.go b/game/aw.go index 5737be3..293226a 100644 --- a/game/aw.go +++ b/game/aw.go @@ -29,12 +29,13 @@ type Awakeman struct { func (aw *Awakeman) Update() error { const ( - ε = 0.2 - restitution = -0.3 - gravity = 0.3 - jumpVelocity = -3.6 - runVelocity = 1.4 - coyoteTime = 5 + ε = 0.2 + restitution = -0.3 + gravity = 0.3 + airResistance = -0.01 // ∴ terminal velocity = 30 + jumpVelocity = -4 + runVelocity = 1.4 + coyoteTime = 5 ) // High-school physics time! Under constant acceleration: @@ -55,8 +56,8 @@ func (aw *Awakeman) Update() error { aw.vy = 0 aw.coyoteTimer = coyoteTime } else { - // Falling. v = v_0 + a, and a is gravity. - aw.vy += gravity + // Falling. v = v_0 + a, and a = gravity + airResistance(v) + aw.vy += gravity + airResistance*aw.vy if aw.coyoteTimer > 0 { aw.coyoteTimer-- }