Phillip Trelford's Array

POKE 36879,255

Tetris

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

Comments (5) -

  • Apali

    6/25/2011 2:48:57 PM |

    Great, now make it playable.

  • reno

    6/25/2011 3:10:26 PM |

    Sweet!  Thxs for the code also!

  • Don

    6/26/2011 2:39:03 AM |

    Nice sample, lovely code Smile

    I think it needs the space-bar-drops-brick-to-the-bottom?

  • Phil

    6/28/2011 1:13:59 AM |

    Thanks Don,

    You can now press the down arrow key to drop the bricks quickly to the bottom.

  • Sam

    10/4/2012 9:36:31 PM |

    fantastic game!

Pingbacks and trackbacks (3)+

Comments are closed