diff --git a/BoxBoy/BoxBoy.gd b/BoxBoy/BoxBoy.gd index 786d5df..1f3e179 100644 --- a/BoxBoy/BoxBoy.gd +++ b/BoxBoy/BoxBoy.gd @@ -6,7 +6,7 @@ const MOVE_FORCE: int = 300 #about 10 tiles horizontally (airborne arc) const JUMP_FORCE: int = 500 #about 4 tiles vertically const GRAVITY_RISING: int = 15 -const GRAVITY_FALLING: int = 30 +const GRAVITY_FALLING: int = 60 #bouncy platform const BOUNCE_FORCE: int = -820 #about 10 tiles vertically @@ -43,12 +43,21 @@ func _physics_process(_delta) -> void: velocity.y = -JUMP_FORCE buffer_grounded = 0 buffer_jumping = 0 - - #normally, fall faster than you rise - elif velocity.y < 0 and (Input.is_action_pressed("input_jump") or just_bounced): - velocity.y += GRAVITY_RISING + #normally, fall faster than you rise + smooth apex at peak + if not is_on_floor(): + var grav = GRAVITY_FALLING + if velocity.y < 0 and (Input.is_action_pressed("input_jump") or just_bounced): + grav = GRAVITY_RISING + else: + grav = GRAVITY_FALLING + just_bounced = false # reset here so bounce ascent uses light gravity + + # smooth the transition right at the top + if abs(velocity.y) < 80: + grav = int(grav * 0.65) + + velocity.y += grav else: - velocity.y += GRAVITY_FALLING just_bounced = false #sideways movement