      ; this is meant for testing particle effects
      (comment assoc (particle-effect "particles/fire.p")
             :id :particle)])
+  
   :on-render
   (fn [screen entities]
     (->> (for [entity entities]
            (case (:id entity)
              :fps (doto entity (label! :set-text (str (game :fps))))
-             :bar (let [me (u/get-player (-> main-screen :entities deref))
-                        pct (/ (:health me) (+ (:health me) (:wounds me)))]
-                    (shape entity
-                           :set-color (color :red)
-                           :rect 0 0 u/bar-w u/bar-h
-                           :set-color (color :green)
-                           :rect 0 0 u/bar-w (* u/bar-h pct)))
              entity))
          (render! screen)))
+  
   :on-resize
   (fn [screen entities]
     (height! screen 300)
     (for [e entities]
       (case (:id e)
         :particle (assoc e :x (width screen) :y 0)
-        e))))
+        e)))
+  
+  ; custom function that is invoked in main-screen
+  :on-update-health-bar
+  (fn [screen entities]
+    (for [entity entities]
+      (case (:id entity)
+        :bar (let [me (:entity screen)
+                   pct (/ (:health me) (+ (:health me) (:wounds me)))]
+               (shape entity
+                      :set-color (color :red)
+                      :rect 0 0 u/bar-w u/bar-h
+                      :set-color (color :green)
+                      :rect 0 0 u/bar-w (* u/bar-h pct)))
+        entity))))
 
 (defgame dungeon-crawler
   :on-create

            (e/create-ogres 20)]
           flatten
           (reduce #(e/randomize-locations screen %1 %2) []))))
  :on-render
  (fn [screen entities]
    (clear!)
    (let [me (u/get-player entities)]
      (->> entities
           (map (fn [entity]
                  (->> entity

            [play-clj.core :refer :all]
            [play-clj.g2d :refer :all]
            [play-clj.ui :refer :all]))

(declare dungeon-crawler main-screen npc-health-screen overlay-screen)

(defonce manager (asset-manager))
(set-asset-manager! manager)
