 (ns clojuroids.core
   (:require
-   [cljs.core.async :refer [chan put! take! timeout <!]]
+   [cljs.core.async :refer [alts! timeout <!]]
    [clojuroids.render :as render]
    [clojuroids.ship :as ship]
    [clojuroids.shot :as shot]

   [clojuroids.level :as level]
   [clojuroids.saucer :as saucer])
  (:require-macros
   [cljs.core.async.macros :refer [alt! go-loop]]))

(def frame-rate 33)
(def init-roid-count 4)

(defn game-loop [init-state]
  (let [input-chan (input/user-input)]
    (go-loop [state init-state start (timestamp)]
      (let [[input] (alts! [input-chan] :default nil)
            state (-> state (assoc :input input) (update-state))]
        (animate-frame state)
        (<! (timeout (calc-timeout start)))
        (recur state (timestamp))))))
