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 hidden or 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 } |
Pow pow pow, now it's restartable.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now it works!
@phadej you're right, there has to be a function proceeding the "whole world state". And you have to forget almost everything you've learn about Rx/Bacon.js conventions. There's no temporal composition. Just a big state machine. Yet, the end result is quite nice. Except it's still not restartable.