 
 ;;; }}}
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; {{{ Log Window
-(def log-chan (chan))
-(def log-state (atom {}) )
-
-(defn log-window 
-  [{:keys [in-chan class-name] :as data} owner ]
-  (let [in-chan    (or in-chan (chan)) 
-        class-name (or class-name "pane")]
-    (reify
-      om/IWillMount
-      (will-mount [ this ]
-        (go
-          (om/set-state! owner :text "")
-          (loop []
-            (let [txt (<! in-chan)
-                  txt-req {:text txt}]
-              (om/update-state! owner [:text] #(str % "\n" txt ))
-              (recur)))))
-
-      om/IRenderState
-      (render-state [_ {:keys [text]}]
-        (dom/div
-          #js { :className class-name }
-          (dom/span nil "Logs")
-          (dom/textarea #js {:width "100%" :value text}))))))
-
-(def draggable-log-window (draggable-item log-window [:position]))
-
-;; }}}
-
+;; {{{ Ignore for now
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; {{{ 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))))
+;; }}}
+
+
 ;; {{{ FPS Component
 
 (def time-chan (chan))

                 )))))
;; }}}

; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; {{{ 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

      {: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)
