(common/site-layout
(include-js "/tempest.js")
[:canvas#canv-bg {:width "900" :height "900"
- :style "position: absolute; z-index: 0;"}]
+ :style (str "position: absolute; z-index: 0;"
+ "background-color: #000000;")}]
[:canvas#canv-fg {:width "900" :height "900"
- :style "position: absolute; z-index: 1;"}]
+ :style (str "position: absolute; z-index: 1;")}]
[:p#fps "FPS 0.0"]
(javascript-tag (str "tempest.canvasDraw(" (pr-str level) ");"))
))
(events/listen handler "key" (fn [e] (c/queue-keypress e)))
(let [empty-game-state (c/build-game-state)
- game-state (assoc
- (c/change-level
- (assoc empty-game-state
- :context context
- :bgcontext bgcontext
- :dims dims
- :anim-fn (c/animationFrameMethod)
- :enemy-list )
- level-idx)
- :enemy-list (enemy-on-each-segment
- (get levels/*levels* level-idx)))]
+ game-state (c/change-level
+ (assoc empty-game-state
+ :context context
+ :bgcontext bgcontext
+ :dims dims
+ :anim-fn (c/animationFrameMethod)
+ :enemy-list )
+ level-idx)]
(c/next-game-state game-state))))
game-state]
(if (not (:is-dead? player))
(draw/draw-player context dims level player))
- (draw/draw-entities context dims level enemy-list)
- (draw/draw-entities context dims level projectile-list)
+ (draw/draw-entities context dims level enemy-list {:r 150 :g 10 :b 10})
+ (draw/draw-entities context dims level projectile-list {:r 255 :g 255 :b 255})
game-state))
(defn remove-collided-entities
[context dims level player]
(doseq []
(.beginPath context)
+ (set! (. context -strokeStyle) (str "rgb(255,255,0)"))
(draw-path context
(path/polar-to-cartesian-centered
(path/polar-entity-coord player)
"Draws all the entities, defined by paths in 'entity-list', on the 2D context
of an HTML5 canvas, with :height and :width specified in dims, and on the
given level."
- [context dims level entity-list]
- (doseq [entity entity-list]
- (.beginPath context)
- (draw-path-rotated context
- (path/polar-to-cartesian-centered
- (path/polar-entity-coord entity)
- dims)
- (path/round-path ((:path-fn entity) entity))
- true
- (:flip-point entity)
- (:flip-cur-angle entity))
- (.closePath context)))
-
+ [context dims level entity-list color]
+ (let [{r :r g :g b :b} color
+ color-str (str "rgb(" r "," g "," b ")")]
+ (doseq [entity entity-list]
+ (.beginPath context)
+ (.log js/console color-str)
+ (set! (. context -strokeStyle) color-str)
+ (draw-path-rotated context
+ (path/polar-to-cartesian-centered
+ (path/polar-entity-coord entity)
+ dims)
+ (path/round-path ((:path-fn entity) entity))
+ true
+ (:flip-point entity)
+ (:flip-cur-angle entity))
+ (.closePath context))))
+
(defn draw-board
"Draws a level on a 2D context of an HTML5 canvas with :height and :width
specified in dims."
(.save context)
(.scale context zoom zoom)
(.beginPath context)
+ (set! (. context -strokeStyle) (str "rgb(10,10,100)"))
(doseq [idx (range (count (:segments level)))]
(draw-rectangle
context