diff --git a/common/src/play_clj/core.clj b/common/src/play_clj/core.clj index 86c6371..7f7680e 100644 --- a/common/src/play_clj/core.clj +++ b/common/src/play_clj/core.clj @@ -36,10 +36,13 @@ (->> entity (conj (:entities @screen)) (swap! screen assoc :entities))) - del-entity (fn [entity] + rem-entity (fn [entity] (->> (:entities @screen) (remove #(= % entity)) - (swap! screen assoc :entities)))] + (swap! screen assoc :entities))) + upd-entity (fn [entity args] + (rem-entity entity) + (add-entity (apply assoc entity args)))] (proxy [Screen] [] (show [] (swap! screen assoc @@ -48,7 +51,8 @@ :total-time 0 :entities [] :add-entity add-entity - :del-entity del-entity) + :rem-entity rem-entity + :upd-entity upd-entity) (on-show @screen)) (render [delta-time] (swap! screen assoc :total-time (+ (:total-time @screen) delta-time)) @@ -68,8 +72,12 @@ (add-entity e)) (defn remove-entity! - [{:keys [del-entity]} e] - (del-entity e)) + [{:keys [rem-entity]} e] + (rem-entity e)) + +(defn update-entity! + [{:keys [upd-entity]} e & args] + (upd-entity e args)) (defn set-screen! [^Game game ^Screen screen] diff --git a/common/src/play_clj/render.clj b/common/src/play_clj/render.clj index 668d282..b117b76 100644 --- a/common/src/play_clj/render.clj +++ b/common/src/play_clj/render.clj @@ -65,6 +65,6 @@ (.begin batch) (doseq [{:keys [image x y width height]} entities] (when (and image x y width height) - (.draw batch image x y width height))) + (.draw batch image (float x) (float y) (float width) (float height)))) (.end batch) batch)))