From 1c67c0c4a415fe7163ffb4e0fb98a2118c5a621f Mon Sep 17 00:00:00 2001 From: Travis Shears Date: Fri, 8 May 2026 16:53:01 +0200 Subject: [PATCH] get cal-vision-points sorted properly --- game/src/entities/player.fnl | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/game/src/entities/player.fnl b/game/src/entities/player.fnl index bda7495..576e284 100644 --- a/game/src/entities/player.fnl +++ b/game/src/entities/player.fnl @@ -47,12 +47,10 @@ (lambda player.cal-vision-points [self] - (let [pts [] + (let [ (ox oy) (origin-pt self.x self.y) - add-pt (lambda [x y] - (let [(rx ry) (utils.rotate-pt x y ox oy self.rot)] - (table.insert pts [rx ry]))) - ] + pts []] + (lambda add-pt [x y] (table.insert pts [x y])) (for [i 1 5] (add-pt (- ox (* i 5) 50) (- oy (- 50 (* i 5) )))) (for [i 1 10] @@ -62,7 +60,13 @@ (add-pt (+ ox (* i 5)) (- oy 50))) (for [i 1 5] (add-pt (+ ox (* i 5) 50) (- oy (- 50 (* i 5) )))) - pts + (table.sort pts (lambda [a b] (let [x1 (. a 1) x2 (. b 1)] + (> x1 x2)))) + (icollect [_ pt (ipairs pts)] + (let [ + [x y] pt + (rx ry) (utils.rotate-pt x y ox oy self.rot)] + [rx ry])) ) )