diff --git a/src/play_clj/core_2d.clj b/src/play_clj/core_2d.clj index 54a574c..d583b38 100644 --- a/src/play_clj/core_2d.clj +++ b/src/play_clj/core_2d.clj @@ -77,7 +77,7 @@ (defmacro animation [duration textures & args] `(Animation. ~duration - (u/convert-array (map :object ~textures)) + (u/gdx-array (map :object ~textures)) (u/static-field-upper :graphics :g2d :Animation ~(or (first args) :normal)))) diff --git a/src/play_clj/utils.clj b/src/play_clj/utils.clj index 3df8394..05c3f4b 100644 --- a/src/play_clj/utils.clj +++ b/src/play_clj/utils.clj @@ -1,8 +1,10 @@ (ns play-clj.utils (:require [clojure.string :as s]) (:import [com.badlogic.gdx.graphics.g2d TextureRegion] - [com.badlogic.gdx.utils Array] - [com.badlogic.gdx.scenes.scene2d Actor])) + [com.badlogic.gdx.scenes.scene2d Actor] + [com.badlogic.gdx.utils Array ArrayMap])) + +; converting keys (def ^:const main-package "com.badlogic.gdx") @@ -52,9 +54,20 @@ [& args] `~(static-field args key->upper)) -(defn convert-array - [a] - (Array. true (into-array a) 1 (count a))) +; data structures + +(defn gdx-array + [arr] + (Array. true (into-array arr) 1 (count arr))) + +(defn gdx-array-map + [hmap] + (let [amap (ArrayMap.)] + (doseq [[k v] hmap] + (.put amap k v)) + amap)) + +; java interop (defmacro call! [obj k & args] @@ -73,6 +86,8 @@ [obj & args] `(doto ~obj ~@(create-method-calls [] args))) +; entities + (defmulti create-entity class) (defmethod create-entity TextureRegion