Commits

ptrelford committed c718a52

Lives reduced when pacman touched

  • Participants
  • Parent commits eb05a2e

Comments (0)

Files changed (1)

PacMan.Xaml/PacMan.fs

     let pd = load "pd1", load "pd2"
     let pl = load "pl1", load "pl2"
     let pr = load "pr1", load "pr2"
-    let lives = [for _ in 1..2 -> load "pl1"]
+    
+    let mutable lives = [for _ in 1..9 -> load "pl1"]
     do  lives |> List.iteri (fun i life -> add life; set life (16+16*i,32*8))
+    do  lives <- lives |> List.rev
+    let decLives () =
+        lives <-
+            match lives with
+            | [] -> []
+            | x::xs -> remove x; xs
 
     let ghost_starts = 
         [
         powerCount <- powerCount - 1
 
     let mutable flashCount = 0
+
     let updateFlash () =
         if flashCount > 0 then
             if ((flashCount / 5) % 2) = 1 then (!pacman).SetOpacity(0.5)
             else (!pacman).SetOpacity(1.0)
+            flashCount <- flashCount - 1
         else (!pacman).SetOpacity(1.0)
-        flashCount <- flashCount - 1
 
     let touchGhosts () =
         let px, py = !x, !y
                     { ghost with IsReturning = true; }
                 else ghost
             )
-            else flashCount <- 20
+            else
+                if flashCount = 0 then
+                    decLives()
+                    flashCount <- 30
 
     let updateBonuses () =
         let removals,remainders =