Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Chapter09/MainGame/Gameplay.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
[<Measure>]
type s
Expand All @@ -20,7 +25,7 @@ type pix

type City =
{ Name : string
Population : float32<h>
Population : int<h>
Position : TypedVector2<m>
}

Expand Down Expand Up @@ -213,7 +218,7 @@ let update (random : System.Random) (world : World) (dt : float32<s>) 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<h>
) survivors
)
Expand Down
6 changes: 3 additions & 3 deletions Chapter09/MainGame/InputStateMachine.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -25,4 +25,4 @@ let waitReleased pressed released func =
waitReleased result
|> Active

waitPressed
waitPressed()
1 change: 0 additions & 1 deletion Chapter09/MainGame/TypedVector.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down