File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -487,6 +487,18 @@ proc main() =
487487 case key
488488 of XK_EQUAL : scrollUp ()
489489 of XK_MINUS : scrollDown ()
490+ of XK_h, XK_Left:
491+ let newX = camera.position.x - config.camera_speed
492+ camera.position = vec2 (newX, camera.position.y)
493+ of XK_j, XK_Down:
494+ let newY = camera.position.y + config.camera_speed
495+ camera.position = vec2 (camera.position.x, newY)
496+ of XK_k, XK_Up:
497+ let newY = camera.position.y - config.camera_speed
498+ camera.position = vec2 (camera.position.x, newY)
499+ of XK_l, XK_Right:
500+ let newX = camera.position.x + config.camera_speed
501+ camera.position = vec2 (newX, camera.position.y)
490502 of XK_0 :
491503 camera.scale = 1.0
492504 camera.deltaScale = 0.0
Original file line number Diff line number Diff line change @@ -5,12 +5,14 @@ type Config* = object
55 scroll_speed* : float
66 drag_friction* : float
77 scale_friction* : float
8+ camera_speed* : float
89
910const defaultConfig* = Config (
1011 min_scale: 0.01 ,
1112 scroll_speed: 1.5 ,
1213 drag_friction: 6.0 ,
1314 scale_friction: 4.0 ,
15+ camera_speed: 20.0 ,
1416)
1517
1618proc loadConfig * (filePath: string ): Config =
@@ -31,6 +33,8 @@ proc loadConfig*(filePath: string): Config =
3133 result .drag_friction = parseFloat (value)
3234 of " scale_friction" :
3335 result .scale_friction = parseFloat (value)
36+ of " camera_speed" :
37+ result .camera_speed = parseFloat (value)
3438 else :
3539 quit " Unknown config key `$#`" % [key]
3640
@@ -41,3 +45,4 @@ proc generateDefaultConfig*(filePath: string) =
4145 f.write (" scroll_speed = " , defaultConfig.scroll_speed, " \n " )
4246 f.write (" drag_friction = " , defaultConfig.drag_friction, " \n " )
4347 f.write (" scale_friction = " , defaultConfig.scale_friction, " \n " )
48+ f.write (" camera_speed = " , defaultConfig.camera_speed, " \n " )
You can’t perform that action at this time.
0 commit comments