Fixes bug in Firefox that caused levels not to display
:enemy-list '())))
(defn maybe-change-level
+ "Reloads or moves to the next level if player is dead, or if all enemies are
+ dead."
[game-state]
(let [player (:player game-state)
level (:level game-state)]
))
(defn projectiles-after-shooting
+ "Returns a new list of active projectiles after randomly adding shots from
+ enemies."
[enemy-list projectile-list]
(loop [[enemy & enemies] enemy-list
projectiles projectile-list]
(recur enemies projectiles)))))
(defn maybe-enemies-shoot
+ "Randomly adds new projectiles coming from enemies based on the enemies'
+ shoot-probability field. See projectiles-after-shooting."
[game-state]
(let [enemies (:enemy-list game-state)
projectiles (:projectile-list game-state)]
(= (:step flipper) 50)
(= (:step flipper) 100)
(= (:step flipper) 150)
- (= (:step flipper) 200)
+ (= (:step flipper) (:steps (:level flipper)))
)
(= (:flip-dir flipper) (DirectionEnum "NONE")))
permanent-dir (:flip-permanent-dir flipper)
[context dims level zoom]
(doseq []
(.save context)
- (.scale context zoom zoom)
+ ;; To fix bug in Firefox. scale to 0.0 breaks it.
+ (if (zero? zoom)
+ (.scale context 0.00001 0.0001)
+ (.scale context zoom zoom))
(.beginPath context)
(set! (. context -strokeStyle) (str "rgb(10,10,100)"))
(doseq [idx (range (count (:segments level)))]
dims
(path/rectangle-for-segment level idx)))))
(.closePath context)
- (.restore context)))
+ (.restore context)
+ ))
;; (path/round-path (map #(list (+ (- (:width dims) (* (:width dims) zoom)) (first %)) (peek %)) (path/rectangle-to-canvas-coords dims (path/rectangle-for-segment level idx)))))
(def *level7_lines* (vec (oblong-level [135 45 135 45] 15 3)))
+;; Oblong level, an open "W"
+(def *level8_lines* (vec (oblong-level [135 105 90 33] 8 10)))
+
(defn make-level-entry
"Make a map that defines a level. A level contains a vector of lines, a
This function takes a vector of lines, and a boolean specifying whether
the level is a closed loop, or open."
[lines loops? enemy-count enemy-probability &
- {:keys [length-fn] :or {length-fn *default-length-fn*}}]
+ {:keys [length-fn steps] :or {length-fn *default-length-fn*
+ steps *default-steps-per-segment*}}]
{:lines lines
:loops? loops?
:segments (build-segment-list (- (count lines) 1) loops?)
:length-fn length-fn
- :steps *default-steps-per-segment*
+ :steps steps
:remaining enemy-count
:probability enemy-probability})
{:flipper 0.01})
(make-level-entry *level7_lines* false
{:flipper 20}
- {:flipper 0.01})])
+ {:flipper 0.01})
+ (make-level-entry *level8_lines* false
+ {:flipper 20}
+ {:flipper 0.01}
+ :length-fn #(* 10 %)
+ :steps 400)
+ ])