                  )))))
 ;; }}}
 
-; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; {{{ Timer
-(defprotocol ITimer
-  (tick! [_]))
-
-(defn is-valid? [{:keys [previous now] :as c}]
-  (not (or
-         (nil? previous)
-         (nil? now))))
-
-(defn time-passed [{:keys [previous now] :as c}]
-  (if (is-valid? c)
-    (- now previous)
-    0))
-
-(defn html-timer []
-  (let [c (atom {:previous nil
-                 :now nil})]
-    (reify ITimer
-      (tick! [_]
-        (do
-          (swap!  c assoc
-               :previous (:now @c)
-               :now (.now js/performace)))
-        (if (is-valid? @c)
-          (- (:now @c) (:previous @c))
-          0)))))
-
-;; }}}
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; {{{ Every Frame
-(defprotocol IEveryFrame
-  (get-fps [_])
-  (get-ms-per-frame [_])
-  (every [_ f]))
-;; }}}
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; {{{ Timer
-(def my-timer (html-timer))
-
-(defn animate [f]
-  (do
-    (.requestAnimationFrame js/window animate)
-    (let [dt (tick! my-timer)]
-      (when (not= dt 0)
-        (f dt)))))
-
-;;; }}}
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; {{{ Log Window


(defn html-timer []
  (let [c (atom {:previous nil
                 :now nil})]
    (reify ITimer
      (tick! [_]
        (do
          (swap!  c assoc
               :previous (:now @c)
               :now (.now js/performace)))
        (if (is-valid? @c)
          (- (:now @c) (:previous @c))
          0)))))

(def my-timer (html-timer))

(defn animate [f]
  (do
    (.requestAnimationFrame js/window animate)
    (let [dt (tick! my-timer)]
      (when (not= dt 0)
        (f dt)))))

;; }}}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; {{{ Game obect
(def pogue-game
  (game/make-game
    (reify 
      game/IGameInit
      (game-init [this]
        this)

      game/IGameUpdate
      (game-update [this dt]
        this)

      game/IGameClose
      (game-close [this]
        this))))
;; }}}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; {{{ Main

(defonce first-time? (atom true))

(when @first-time?
    (do
      (swap! first-time? not)
      (js/setInterval (fn [] (put! time-chan (/ 1 60))) 16))) 

(defn main []
  (do

      {:in-chan time-chan :class-name "pane" }
      {:target (by-id "test") })

    (let [rm (rmhtml/mk-resource-manager "resources")
          _ (clear-resources! rm)
          ; img-chan (load-img! rm "tiles")
          rend (create-render-target! rm "shit" 300 300) ]
      )) 

  ; {{{

    ; (om/root
    ;   draggable-log-window
    ;   {:in-chan log-chan :class-name "pane" :position {:left 100 :top 20}}
    ;   {:target (by-id "app")})

  ; (let [rm (rmhtml/mk-resource-manager "resources")
  ;       _ (clear-resources! rm)
