Phil Trelford's Array
POKE 36879, 255

Lunar Landurz

January 6, 2011 22:03 by phil

In F# integer and floating point values can be associated with units of measure, typically used to indicate lengths, mass, etc. F# units of measure give compile time type safety with no runtime performance penalty!.Below is a playable Silverlight mini-game that applies units of measures in F# to 2D game mechanics.

Keys: Z = Left, X = Right, Space = Thrust

 

To complete the game you must land your craft on the flat ground (to make it a little easier the speed of landing and the orientation of the craft are not significant.

Note: this is a port of an XNA sample I wrote back in 2008.

Gravity

Use the Measure attribute to define your own measure types :

[<Measure>]
type m
[<Measure>]
type s

module Gravity = 
    let Earth = 9.8<m/s^2> // Standard Gravity
    let Lunar = Earth / 6.0 

Code: https://bitbucket.org/ptrelford/lunarlandurz

References:


Tags:
Categories: .Net | F# | Silverlight
Actions: E-mail | Permalink | Comments (2) | Comment RSSRSS comment feed

Comments

January 7. 2011 10:13

MBR

Nice... - I love vector gfx games - to me they're still more compelling than fully shaded/textured gfx.
Let's see some gfx for the main and retro thrust :)
Tho' this is easier to play with analog controls for varied thrust...

MBR

May 26. 2012 12:45

trackback

GOTO Copenhagen 2012 Conference

GOTO Copenhagen 2012 Conference

Phil Trelford's Array

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading