 (defn draw-game [game screen]
   (.clear screen)
   (doseq [ui (:uis game)]
-    (draw-ui ui game screen)))
+    (draw-ui ui game screen))
+  game)
 
 (defmulti process-input
   (fn [game input]

    (assoc game :uis [])
    (assoc game :uis [{:kind :start}])))

(defn game-loop []
  (when-let [screen (:screen @app-state)]
    (let [input (:input @app-state)
          game (if (nil? input)
                 (:game @app-state)
                 (process-input (:game (swap! app-state dissoc :input))
                                input))]
      (draw-game game screen)
      (swap! app-state assoc :game game)))
  (.requestAnimationFrame js/window #(game-loop)))

(defn init-game! []
  (.requestAnimationFrame js/window #(game-loop)))

(init-game!)

;; -------------------------
;; Views

(defonce key-loop
  (go-loop []
    (when-let [event (<! key-chan)]
      (let [key-code (.. event -keyCode)
            input (get *keys* (if (<= 96 key-code 105)
                                (- key-code 48)
                                key-code))]
        (when (:game @app-state)
          (swap! app-state assoc-in [:game :input] input)))
      (recur))))

(defmulti draw-ui
