Add sorting functions
This commit is contained in:
@@ -1,5 +1,26 @@
|
|||||||
(in-ns 'play-clj.core)
|
(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
|
; tiled maps
|
||||||
|
|
||||||
(defn tiled-map*
|
(defn tiled-map*
|
||||||
@@ -420,7 +441,7 @@ specify which layers to render with or without
|
|||||||
(.begin batch)
|
(.begin batch)
|
||||||
(doseq [entity (->> (map #(get-in screen [:layers %]) layer-names)
|
(doseq [entity (->> (map #(get-in screen [:layers %]) layer-names)
|
||||||
(apply concat entities)
|
(apply concat entities)
|
||||||
(sort #(if (< (:y %1) (:y %2)) 1 -1)))]
|
(high->low :y))]
|
||||||
(if-let [layer (:layer entity)]
|
(if-let [layer (:layer entity)]
|
||||||
(.renderTileLayer renderer layer)
|
(.renderTileLayer renderer layer)
|
||||||
(draw-entity! batch entity)))
|
(draw-entity! batch entity)))
|
||||||
@@ -543,10 +564,3 @@ remains in tact
|
|||||||
(let [^Camera camera (u/get-obj screen :camera)]
|
(let [^Camera camera (u/get-obj screen :camera)]
|
||||||
(set! (. camera far) n)
|
(set! (. camera far) n)
|
||||||
(.update camera)))
|
(.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