Make dragging feel super good Kreygasm

pull/63/head
rexim 5 years ago
parent e0ac5b6299
commit 4643f72634

@ -301,7 +301,10 @@ proc main() =
if mouse.drag:
let delta = world(camera, mouse.prev) - world(camera, mouse.curr)
camera.position += delta
camera.velocity = delta * config.dragVelocityFactor
# delta is the distance the mouse traveled in a single
# frame. To turn the velocity into units/second we need to
# multiple it by FPS.
camera.velocity = delta * config.fps.float
mouse.prev = mouse.curr

@ -2,15 +2,13 @@ import macros, strutils
type Config* = object
scrollSpeed*: float
dragVelocityFactor*: float
dragFriction*: float
scaleFriction*: float
fps*: int
const defaultConfig* = Config(
scrollSpeed: 1.0,
dragVelocityFactor: 10.0,
dragFriction: 2.0,
scrollSpeed: 1.5,
dragFriction: 6.0,
scaleFriction: 4.0,
fps: 60
)

Loading…
Cancel
Save