 (def game-x-cells (pixels->cell game-width))
 (def game-y-cells (pixels->cell game-height))
 
-(defn surface-element
+(def surface
+  (let [surface (dom/getElement "surface")]
+    (set! (.-width surface) game-width)
+    (set! (.-height surface) game-height)
+    surface))
+(def draw-context (.getContext surface "2d"))
+
+(def start-position
+  [(pixels->cell (/ game-width 2))
+   (- (pixels->cell game-height) 1)])
+
+(defn initial-state
   []
-  (dom/getElement "surface"))
+  {:start-time (js/Date.)
+   :state :playing
+   :player start-position} )
 
 (def keycode->key
   {kcs/SPACE :space

    (draw-sprite state 4 4 cell-size :flask)
    (draw-sprite state player-x player-y cell-size :player)
    (draw-text state game-x-cells 0 (str countdown " seconds"))))

(defn render-world
  [state]

  )

(defn draw-sprite
  [state x y size sprite]
  (let [sprite (sprites sprite)
        [x y] (cell->coords x y)]
    (.drawImage draw-context sprite x y size size)))

(defn draw-text
  [state x y text]
  (let [[x y] (cell->coords x y)]
    (set! (.-font draw-context) "bold 1.5em sans-serif")
    (set! (.-textBaseline draw-context) "top")
