               (= (:mode program) :play)
               (< (:step program) num-steps))
             (-> prev-state
-              (update-in [:program :step] inc))
-            prev-state)))))
+              (update-in [:program :step] inc)
+              (update-in [:turtle] apply-step-code
+                (-> program :code (nth (-> program :step inc)))))
+            (apply-stop prev-state))))))
 
 
 
 
-(def turtle-circles
-  [
-    ; body
-    { :cx 0.5 :cy 0.6 :r 0.25 }
-    ; head
-    { :cx 0.5 :cy 0.25 :r 0.1 }
-    ; legs
-    { :cx 0.75 :cy 0.38 :r 0.05 }
-    { :cx 0.25 :cy 0.38 :r 0.05 }
-    { :cx 0.75 :cy 0.83 :r 0.05 }
-    { :cx 0.25 :cy 0.83 :r 0.05 }
-    ])
 
-
-(defn turtle [{:keys [x y rot]}]
+(defn turtle [{:keys [x y dir]}]
   [:g
     {:transform
-      (str "translate(" x "," y ")" "rotate(" rot ")")
+      (str "translate(" x "," y ")" "rotate(" (dir-to-rotation dir) ")")
     }
     (for [c turtle-circles]
         [:circle (merge c  {

   ])


(js/setInterval next-step! 1000)

(reagent/render-component [world]
                          (. js/document (getElementById "app")))

      :mode :stop
      :step 0
      :code [
        [:left]
        [:forward 1]
        [:right]
        [:forward 1]
        [:left]
        [:forward 1]
      ]
    }

