(#54) make scale friction depend on the delta scale

This commit is contained in:
rexim 2019-11-28 01:10:26 +07:00
parent 984b0ea629
commit eea38a2247
2 changed files with 3 additions and 3 deletions

View File

@ -10,8 +10,8 @@ type Config* = object
const defaultConfig* = Config(
scrollSpeed: 1.0,
dragVelocityFactor: 10.0,
dragFriction: 3.0,
scaleFriction: 10.0,
dragFriction: 2.0,
scaleFriction: 4.0,
fps: 60
)

View File

@ -27,7 +27,7 @@ proc update*(camera: var Camera, config: Config, dt: float, mouse: Mouse, image:
let p1 = (mouse.curr - (windowSize * 0.5)) / camera.scale
camera.position += p0 - p1
camera.delta_scale -= sgn(camera.delta_scale).float * config.scale_friction * dt
camera.delta_scale -= camera.delta_scale * dt * config.scale_friction
if not mouse.drag and (camera.velocity.length > VELOCITY_THRESHOLD):
camera.position += camera.velocity * dt