(defn render [world] ^:kind/hiccup [:svg {:style {:border"1px solid black"}} (for [[entity-id {:keys [x y]}] world] (if (= entity-id :player) [:rect {:width50:height50:fill"#62b133":x x :y y :id"player"}] [:circle {:r25:fill"#5880d9":cx x :cy y :id"enemy"}]))])
Now would be a perfect time to use Reagent to connect the user’s keyboard to our world atom. However, I couldn’t get it working with Clay (what we’re using to render this page). The dependencies have won the first battle.
Moving on, we’ll resort to a script element. Clay lets us use JavaScript, but I couldn’t get it to work with curly braces. Suffering a one-liner, we can now move, via WASD on our keyboard.