Playable Silverlight mini-game implemented with a couple of hundred lines of F#!
Keys: Left Arrow = Left, Right Arrow = Right, Up Arrow = Rotate, Down Arrow = Drop
Can also be run as an editable script inside TryFSharp.org.
The main game loop:
let rec gameLoop () = async {
do! prompt "Click To Start" awaitingClick
do! inGameLoop ()
do! prompt "Game Over" paused
well.Clear()
return! gameLoop ()
}
The game makes use of F#’s Asynchronous Workflows to simplify the asynchronous flow. The game loop above looks as if it is run synchronously. But by simply wrapping the code in an async block it can be run asynchronously!
Resources