Add sorting functions
This commit is contained in:
@@ -1,5 +1,26 @@
|
||||
(in-ns 'play-clj.core)
|
||||
|
||||
; misc
|
||||
|
||||
(defmacro usage
|
||||
"Returns a static field in [VertexAttributes.Usage](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/VertexAttributes.Usage.html)"
|
||||
[k]
|
||||
`~(u/gdx-field :graphics "VertexAttributes$Usage" (u/key->pascal k)))
|
||||
|
||||
(defn low->high
|
||||
"Sorts the `entities` by `k` in ascending order
|
||||
|
||||
(low->high :y entities)"
|
||||
[k entities]
|
||||
(sort #(if (< (get %1 k) (get %2 k)) -1 1) entities))
|
||||
|
||||
(defn high->low
|
||||
"Sorts the `entities` by `k` in descending order
|
||||
|
||||
(high->low :y entities)"
|
||||
[k entities]
|
||||
(sort #(if (< (get %1 k) (get %2 k)) 1 -1) entities))
|
||||
|
||||
; tiled maps
|
||||
|
||||
(defn tiled-map*
|
||||
@@ -420,7 +441,7 @@ specify which layers to render with or without
|
||||
(.begin batch)
|
||||
(doseq [entity (->> (map #(get-in screen [:layers %]) layer-names)
|
||||
(apply concat entities)
|
||||
(sort #(if (< (:y %1) (:y %2)) 1 -1)))]
|
||||
(high->low :y))]
|
||||
(if-let [layer (:layer entity)]
|
||||
(.renderTileLayer renderer layer)
|
||||
(draw-entity! batch entity)))
|
||||
@@ -543,10 +564,3 @@ remains in tact
|
||||
(let [^Camera camera (u/get-obj screen :camera)]
|
||||
(set! (. camera far) n)
|
||||
(.update camera)))
|
||||
|
||||
; misc
|
||||
|
||||
(defmacro usage
|
||||
"Returns a static field in [VertexAttributes.Usage](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/VertexAttributes.Usage.html)"
|
||||
[k]
|
||||
`~(u/gdx-field :graphics "VertexAttributes$Usage" (u/key->pascal k)))
|
||||
|
||||
Reference in New Issue
Block a user