                    [schema.core :as sm])
   (:use [cljs.core.async :only [chan <! >! put! timeout]]))
 
-(sm/defschema MoveDirection (s/enum :up :right :down :left))
-(sm/defschema IntendedMoveDirection #{MoveDirection})
+(sm/defschema Direction (s/enum :up :right :down :left))
+(sm/defschema IntendedDirection #{Direction})
 
 (sm/defschema Entity {:id                         s/Int
                       (s/maybe :position)         {:x s/Num

                      (s/maybe :collision-box)    {:width  s/Int
                                                   :height s/Int}
                      (s/maybe :render-info)      {:shape (s/enum :square)}
                      (s/maybe :human-controlled) {:indended-move-direction IntendedMoveDirection
                                                   :intended-fire-direction s/Any}})

(def player {:id               1
             :position         {:x 10
                                :y 10}
             :collision-box    {:width 50 :height 50}
             :render-info      {:shape :square}
             :human-controlled {:intended-move-direction #{}}
             })

; TODO :mode? :active-level?
(def game-state (atom {:entities [player]}))

    (let [msg (<! event-chan)]
      (js/console.log (clj->js msg))
      (case (msg :type)
        :move-key-down (swap! state update-player [:human-controlled :intended-move-direction] conj (msg :direction))
        :move-key-up (swap! state update-player [:human-controlled :intended-move-direction] disj (msg :direction))
        :fire-key-down (swap! state update-player [:human-controlled :intended-fire-direction] conj (msg :direction))
        :fire-key-up (swap! state update-player [:human-controlled :intended-fire-direction] disj (msg :direction)))
      (js/console.log (clj->js (get-in @state [:entities 0 :human-controlled])))
      (recur))))

(defn ^:export main []
