Created
January 26, 2014 20:54
-
-
Save raimohanska/8639343 to your computer and use it in GitHub Desktop.
Sketch for a Lion Chases Princess Game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pow pow pow, now it's restartable.
https://gist.github.com/raimohanska/8653902