Tweak gravity and player physics
This commit is contained in:
parent
6fc5900131
commit
8216e5863b
|
@ -33,13 +33,14 @@ var (
|
|||
|
||||
// Player speeds
|
||||
PlayerMaxVelocity float64 = 7
|
||||
PlayerJumpVelocity float64 = -23
|
||||
PlayerJumpVelocity float64 = -15
|
||||
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
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user