Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:10
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Active Pattern sample from F#, THIS AINT A GAME by ANDREA MAGNORSKY
let (|SpaceKey|) (keyboard:KeyboardInput) =
let (|Hold100ms|) (keyboard:KeyboardInput) =
keyboard.KeyPressedFor(Key.I, 100)
match DualityApp.Keyboard with
| SpaceKey true & Hold100ms false -> playerGo Jump
| SpaceKey true & Hold100ms true -> playerGo DoubleJump
let (|LeftKey|RightKey|OtherKey|) (keyboard:KeyboardInput) =
if keyboard.KeyPressed(Key.Left) then LeftKey
elif keyboard.KeyPressed(Key.Right) then RightKey
else OtherKey "Hi, you pressed a key...well that is interesting :D"
interface ICmpUpdatable with
member this.OnUpdate()=
match DualityApp.Keyboard with
| LeftKey -> playerGo Left
| RightKey-> playerGo Right
| OtherKey s-> ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment