diff --git a/pkg/balance/numbers.go b/pkg/balance/numbers.go index 7e682b8..502ce29 100644 --- a/pkg/balance/numbers.go +++ b/pkg/balance/numbers.go @@ -32,18 +32,19 @@ var ( } // Player speeds - PlayerMaxVelocity float64 = 7 - PlayerJumpVelocity float64 = -23 - PlayerAcceleration float64 = 0.04 // 0.12 - PlayerFriction float64 = 0.1 - SlipperyAcceleration float64 = 0.02 - SlipperyFriction float64 = 0.02 - Gravity float64 = 7 - GravityAcceleration float64 = 0.1 - SwimGravity float64 = 3 - SwimJumpVelocity float64 = -12 - SwimJumpCooldown uint64 = 24 // number of frames of cooldown between swim-jumps - SlopeMaxHeight = 8 // max pixel height for player to walk up a slope + PlayerMaxVelocity float64 = 7 + PlayerJumpVelocity float64 = -15 + PlayerAcceleration float64 = 0.04 // 0.12 + PlayerFriction float64 = 0.1 + SlipperyAcceleration float64 = 0.02 + SlipperyFriction float64 = 0.02 + GravityMaximum float64 = 7 // max pull of gravity + GravityAcceleration float64 = 0.25 // normal gravity acceleration downward + GravityJumpAcceleration float64 = 0.05 // gravity while jumping upward (smoother jumps) + SwimGravity float64 = 3 + SwimJumpVelocity float64 = -12 + SwimJumpCooldown uint64 = 24 // number of frames of cooldown between swim-jumps + SlopeMaxHeight = 8 // max pixel height for player to walk up a slope // Number of game ticks to insist the canvas follows the player at the start // of a level - to overcome Anvils settling into their starting positions so diff --git a/pkg/uix/actor_collision.go b/pkg/uix/actor_collision.go index cacbde6..6baeb14 100644 --- a/pkg/uix/actor_collision.go +++ b/pkg/uix/actor_collision.go @@ -73,14 +73,23 @@ func (w *Canvas) loopActorCollision() error { // Apply gravity to the actor's velocity. if a.hasGravity && !a.Grounded() { //v.Y >= 0 { if !a.Grounded() { - var gravity = balance.Gravity + var ( + gravity = balance.GravityMaximum + acceleration = balance.GravityAcceleration + ) if a.IsWet() { gravity = balance.SwimGravity } + + // If the actor is jumping/moving upwards, apply softer gravity. + if v.Y < 0 { + acceleration = balance.GravityJumpAcceleration + } + v.Y = physics.Lerp( v.Y, // current speed gravity, // target max gravity falling downwards - balance.GravityAcceleration, + acceleration, ) } else { v.Y = 0