canvas: html
Hi!
Today we will build a rogue like game...
First we need to draw something on the "screen".
We do this by calling html
.
Try this out:
(html [:svg {:style {:background "red"}}])
You should see a red canvas get drawn.
Let's put our game inside a function so we can more easily render it:
(defn game []
[:svg {:style {:background "red"}}])
Now we can update the view like so:
(html [game])
Try changing the game slightly:
(defn game[]
[:svg {:style {:background "green"}}])
And then update the view:
(html [game])
We will be drawing charaters on a 200x200 grid...
(defn game []
[:svg {:width 200
:height 200
:on-context-menu #(identity false)
:view-box (str 0 " " 0 " " 200 " " 200)
:pointer-events :all}
(let [x 5
y 4
glyph "@"
type :text]}]
[type {:x (+ (* 20 x) 10) :y (+ (* 20 y) 10)} glyph])])
Update the view and you should see an "@" character displayed.
More to come later...