 
 (defn ^:export main []
     (let [
+        game-state-ref (atom {:pos [0 0]})
+        input-state-ref (atom {:keys (set)})
         canvas (goog.dom/createDom "div" {} "")
         button (goog.dom/createDom "button" {} "Click!")
         tick-timer (Timer. 100)

        [goog :only [Timer]]
        ))

; State (AAAAHAHAHG, don't touch it!)
(def pos (atom [0 100]))
(def keys-pressed (atom (set)))

(def my-code-url "https://github.com/pauldoo/scratch/blob/master/ClojureScript/hello.cljs")

(defn print-to-log [v]
    (.log js/console v))

(defn input-event [event]
    (cond
        (= (.type event) goog.events.EventType/KEYUP)
            (swap! keys-pressed disj (.keyCode event))
        (= (.type event) goog.events.EventType/KEYDOWN)
            (swap! keys-pressed conj (.keyCode event))
        :else
            nil))

(defn tick []
    (swap! pos (fn [[x y]] [(inc x) (* (count (deref keys-pressed)) 50)])))

(defn rerender [canvas-element]
    (let [[x y] (deref pos)
        graphics (goog.graphics/createGraphics 400 300)]
        (do
            (.drawCircle graphics x y 30 (Stroke. 2 "green") (SolidFill. "yellow"))

        (do
            (. tick-timer (start))
            (. render-timer (start))
            (goog.events/listen button goog.events.EventType/CLICK (partial input-event input-state-ref))
            (goog.events/listen document.body goog.events.EventType/KEYDOWN (partial input-event input-state-ref) true)
            (goog.events/listen document.body goog.events.EventType/KEYUP (partial input-event input-state-ref) true)
            (goog.events/listen tick-timer goog.Timer/TICK #(tick game-state-ref (deref input-state-ref)))
            (goog.events/listen render-timer goog.Timer/TICK #(rerender canvas (deref game-state-ref)))
            (goog.dom/appendChild document.body (goog.dom/createDom "div" {}
                (goog.dom/createDom "h1" {} "Work in progress..")
                (goog.dom/createDom "div" {} "Try clicking the button, or pressing keys.")
