Skip to content

Instantly share code, notes, and snippets.

@raimohanska
Created January 26, 2014 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raimohanska/8639343 to your computer and use it in GitHub Desktop.
Save raimohanska/8639343 to your computer and use it in GitHub Desktop.
Sketch for a Lion Chases Princess Game
module PrincessVsLion where
import Keyboard
-- character positions
princess = foldp inc 4 (pressesOf Keyboard.space)
lion = foldp inc 0 (fps 2)
-- combined game state
gameState = lift2 makeState princess lion
-- main function
main = lift asText gameState
-- helpers
pressesOf key = keepIf id False key
inc _ prev = prev + 1
makeState p l = { princess= p, lion= l }
@raimohanska
Copy link
Author

Pow pow pow, now it's restartable.

https://gist.github.com/raimohanska/8653902

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment