 (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]

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

(defmulti draw-ui

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

(defn handle-input [game]
  (if-let [input (:input game)]
    (-> game
        (process-input input)
        (dissoc :input))
    game))

(defn tick-game []
  (when-let [screen (:screen @app-state)]
    (let [game (:game @app-state)]
      (swap! app-state assoc :game
             (-> game
                 handle-input
                 (draw-game screen))))))

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

(game-loop!)

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