diff --git a/Chapter09/MainGame/Gameplay.fs b/Chapter09/MainGame/Gameplay.fs index dfb86fa..fbda04d 100644 --- a/Chapter09/MainGame/Gameplay.fs +++ b/Chapter09/MainGame/Gameplay.fs @@ -2,6 +2,11 @@ open Microsoft.Xna.Framework + +// Converts an int<'M> to a float32<'M> +let conv (x : int<'M>) = + LanguagePrimitives.Float32WithMeasure<'M>(float32 x) + // Seconds [] type s @@ -20,7 +25,7 @@ type pix type City = { Name : string - Population : float32 + Population : int Position : TypedVector2 } @@ -213,7 +218,7 @@ let update (random : System.Random) (world : World) (dt : float32) orders sta 0.0f else 1.0f - distance/Explosion.Radius - let casualties = city.Population * relativeCasualties + let casualties = (conv city.Population) * relativeCasualties max (survivors - casualties) 0.0f ) survivors ) diff --git a/Chapter09/MainGame/InputStateMachine.fs b/Chapter09/MainGame/InputStateMachine.fs index ca2f685..ae24441 100644 --- a/Chapter09/MainGame/InputStateMachine.fs +++ b/Chapter09/MainGame/InputStateMachine.fs @@ -8,13 +8,13 @@ type InputStateMachine<'InputState, 'Result> = // Used for selecting the controlling played in the "press start" screen. // Also used for pausing/resuming during gameplay. let waitReleased pressed released func = - let rec waitPressed = + let rec waitPressed() = fun (inputState) -> if pressed(inputState) then let result = func inputState waitReleased result else - waitPressed + waitPressed() |> Active and waitReleased result = @@ -25,4 +25,4 @@ let waitReleased pressed released func = waitReleased result |> Active - waitPressed + waitPressed() diff --git a/Chapter09/MainGame/TypedVector.fs b/Chapter09/MainGame/TypedVector.fs index bfa3b5c..1ed809d 100644 --- a/Chapter09/MainGame/TypedVector.fs +++ b/Chapter09/MainGame/TypedVector.fs @@ -30,7 +30,6 @@ module TypedVector = LanguagePrimitives.Float32WithMeasure<'M> (U.v.Length()) let scale2 (k : float32<'K>, U : TypedVector2<'M>) : TypedVector2<'K 'M> = - let conv = LanguagePrimitives.Float32WithMeasure<'K 'M> let v = Vector2.Multiply(U.v, float32 k) TypedVector2(v)