get cal-vision-points sorted properly
This commit is contained in:
parent
1045fdc386
commit
1c67c0c4a4
1 changed files with 10 additions and 6 deletions
|
|
@ -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]))
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue