diff --git a/samples/space-invaders-clone/Player.fs b/samples/space-invaders-clone/Player.fs index 8a81728..7ec480f 100644 --- a/samples/space-invaders-clone/Player.fs +++ b/samples/space-invaders-clone/Player.fs @@ -39,7 +39,7 @@ let update message model = let pos = model.x + playerWidth / 2, resHeight - (playerHeight + padding) - projectileHeight - 1 { model with laser = Some pos } -let view model dispatch = +let view model dispatch freeze = match model.state with | Alive -> [ @@ -49,12 +49,13 @@ let view model dispatch = | Some (x, y) -> yield colour Colour.White (projectileWidth, projectileHeight) (x, y) | _ -> - yield onkeydown Keys.Space (fun () -> dispatch Shoot) + if not freeze then yield onkeydown Keys.Space (fun () -> dispatch Shoot) - yield whilekeydown Keys.Left (fun () -> dispatch (Move -1)) - yield whilekeydown Keys.A (fun () -> dispatch (Move -1)) - yield whilekeydown Keys.Right (fun () -> dispatch (Move 1)) - yield whilekeydown Keys.D (fun () -> dispatch (Move 1)) + if not freeze then + yield whilekeydown Keys.Left (fun () -> dispatch (Move -1)) + yield whilekeydown Keys.A (fun () -> dispatch (Move -1)) + yield whilekeydown Keys.Right (fun () -> dispatch (Move 1)) + yield whilekeydown Keys.D (fun () -> dispatch (Move 1)) ] | Dying _ -> [ diff --git a/samples/space-invaders-clone/Program.fs b/samples/space-invaders-clone/Program.fs index 4340445..d44a7d1 100644 --- a/samples/space-invaders-clone/Program.fs +++ b/samples/space-invaders-clone/Program.fs @@ -176,7 +176,7 @@ let view model dispatch = yield text "SCORE" (10, 10) yield text (sprintf "%04i" model.score) (10, 44) - yield! Player.view model.player (PlayerMessage >> dispatch) + yield! Player.view model.player (PlayerMessage >> dispatch) model.freeze yield! model.bunkers |> List.map (fun r ->