Update animationFrameMethod again to use dictionary lookup of method names as strings. This doesn't really add anything, but it looks a little nicer. Also added marginalia support and fixed some of the comments to look better.
(defproject tempest-cljs "0.1.0-SNAPSHOT"
- :description "FIXME: write this!"
+ :description "Clone of Tempest vector-graphic arcade game."
:dependencies [[org.clojure/clojure "1.3.0"]
[noir "1.2.1"]]
+ :dev-dependencies [[lein-marginalia "0.7.0-SNAPSHOT"]]
:plugins [[lein-cljsbuild "0.1.3"]]
:cljsbuild {
:builds [{:source-path "tempest"
;;
;;
;; Rough design notes:
+;;
;; * Nearly everything is defined with polar coordinates (length and angle)
;; * "Entities" are players, enemies, projectiles
;; * "Entities" are defined by a path, a series of polar coordinates, that
;; towards the player.
;;
;; Obscure design oddities:
+;;
;; * draw-path can optionally follow, but not draw, the first line of an
;; entity's path. There is a crazy reason for this. The 'center' of
;; an entity when drawn ends up being the first point drawn. The first
;;
;; TODO:
+;;
;; * BUG: there's an extra segment at the top of level 6 with no width
;; * Bullet updates should check if they hit or passed over an enemy
;; * Flippers should.. flip.
(defn animationFrameMethod []
(let [window (dom/getWindow)
- options (list #(.-requestAnimationFrame window)
- #(.-webkitRequestAnimationFrame window)
- #(.-mozRequestAnimationFrame window)
- #(.-oRequestAnimationFrame window)
- #(.-msRequestAnimationFrame window))]
+ names ["requestAnimationFrame"
+ "webkitRequestAnimationFrame"
+ "mozRequestAnimationFrame"
+ "oRequestAnimationFrame"
+ "msRequestAnimationFrame"]
+ options (map (fn [name] #(aget window name)) names)]
((fn [[current & remaining]]
(cond
(nil? current) #((.-setTimeout window) % (/ 1000 30))