summary history branches tags files
commit:7129ba2ef7fb25dccfc747880a87d6612e87ca69
author:mrmekon
committer:mrmekon
date:Sat Apr 7 12:51:43 2012 -0400
parents:255b111638835ee3feafb2e27a4ee6479ca2bf3d
Fixes bug in Firefox that caused levels not to display
diff --git a/tempest/tempest/core.cljs b/tempest/tempest/core.cljs
line changes: +7/-1
index 7f43cda..eb80715
--- a/tempest/tempest/core.cljs
+++ b/tempest/tempest/core.cljs
@@ -131,6 +131,8 @@ after passing through all the other functions.  This implements the game loop.
       :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)]
@@ -205,6 +207,8 @@ after passing through all the other functions.  This implements the game loop.
     ))
 
 (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]
@@ -216,6 +220,8 @@ after passing through all the other functions.  This implements the game loop.
           (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)]
@@ -354,7 +360,7 @@ flipper appears to flip 'inside' the level:
                       (= (: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)

diff --git a/tempest/tempest/draw.cljs b/tempest/tempest/draw.cljs
line changes: +6/-2
index d36ca3b..2c856b8
--- a/tempest/tempest/draw.cljs
+++ b/tempest/tempest/draw.cljs
@@ -134,7 +134,10 @@ level functions to draw complete game entities using the primitives.
   [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)))]
@@ -144,7 +147,8 @@ level functions to draw complete game entities using the primitives.
                          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)))))
 

diff --git a/tempest/tempest/levels.cljs b/tempest/tempest/levels.cljs
line changes: +13/-3
index 6e788e5..dd1affe
--- a/tempest/tempest/levels.cljs
+++ b/tempest/tempest/levels.cljs
@@ -249,6 +249,9 @@ Functions related to generating paths representing levels.
 (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
@@ -256,12 +259,13 @@ Functions related to generating paths representing levels.
    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})
 
@@ -287,6 +291,12 @@ Functions related to generating paths representing levels.
                       {: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)
+    ])