biscuit

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 264b2282004218a785471750561ec6505fa379e8
parent 6ecfc60ceec1dd4f45e6a52e5d4160968e16ac7f
Author: Daniel Barlow <dan@telent.net>
Date:   Wed, 11 Mar 2026 00:38:17 +0000

make rotation less lurchy

Diffstat:
Mpkgs/maps/main.fnl | 23+++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/pkgs/maps/main.fnl b/pkgs/maps/main.fnl @@ -97,6 +97,7 @@ label.readout { :courses [0 0 0] :orientation-target 0 ; map rotation angle from north :orientation-actual 0 ; map rotation angle from north + :rotation-speed 0 :tiles {} } ) @@ -380,9 +381,27 @@ label.readout { ; (-> state-widgets.rose (: :get_window) (: :invalidate_rect nil)) (set map-surface nil)) + (when (not (= app-state.orientation-target app-state.orientation-actual)) - (set app-state.orientation-actual - (turn-smoothly app-state.orientation-actual app-state.orientation-target))) + (let [distance (- app-state.orientation-target app-state.orientation-actual) + direction (if (> distance 0) 1 -1) + abs-distance (* direction distance) + max-accel 0.2 + max-speed (* 0.9 (math.sqrt (* 2 max-accel abs-distance)))] + (if (> (math.abs app-state.rotation-speed) max-speed) + (set app-state.rotation-speed (* direction max-speed)) + (set app-state.rotation-speed + (let [a + (+ app-state.rotation-speed + (* direction + (math.min + max-accel + (- max-speed (math.abs app-state.rotation-speed)))))] + (if (< -0.2 a 0.2) 0 a)))))) + + (set app-state.orientation-actual (+ app-state.orientation-actual + app-state.rotation-speed)) + (each [name widget (pairs state-widgets)] (case name :speed (widget:set_label