From 1f33135b58fc12f0e4f7e661e0c5a64498e17815 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 16 Dec 2020 08:24:54 -0500 Subject: node-2d: Improve position interpolation logic. --- starling/node-2d.scm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'starling') diff --git a/starling/node-2d.scm b/starling/node-2d.scm index f6dc7c1..6fd80ba 100644 --- a/starling/node-2d.scm +++ b/starling/node-2d.scm @@ -285,9 +285,8 @@ (define-method (teleport (node ) x y) (move-to node x y) - (let ((lp (last-position node))) - (set-vec2-x! lp x) - (set-vec2-y! lp y))) + (set-vec2! (last-position node) x y) + (set-vec2! (render-position node) x y)) (define-method (rotate-to (node ) theta) (set! (rotation node) theta) @@ -372,8 +371,7 @@ (lp (last-position node)) (rp (render-position node)) (beta (- 1.0 alpha))) - (unless (and (= (vec2-x lp) (vec2-x rp)) - (= (vec2-y lp) (vec2-y rp))) + (unless (and (vec2= rp p) (vec2= lp p)) (set-vec2-x! rp (+ (* (vec2-x p) alpha) (* (vec2-x lp) beta))) (set-vec2-y! rp (+ (* (vec2-y p) alpha) (* (vec2-y lp) beta))) (set! (dirty-matrix? node) #t))) -- cgit v1.2.3