diff options
author | Andrew Cady <d@jerkface.net> | 2014-01-13 22:46:03 -0500 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2014-01-13 22:46:03 -0500 |
commit | 9c0f90e501f407d21d497829fa2fd727fe0c1039 (patch) | |
tree | dbd7c25474f521b155b2e3d4a16c99c784a65a2d |
Initial commit.
-rw-r--r-- | Setup.hs | 2 | ||||
-rw-r--r-- | axis-of-eval.cabal | 21 | ||||
-rw-r--r-- | axis.hs | 36 |
3 files changed, 59 insertions, 0 deletions
diff --git a/Setup.hs b/Setup.hs new file mode 100644 index 0000000..9a994af --- /dev/null +++ b/Setup.hs | |||
@@ -0,0 +1,2 @@ | |||
1 | import Distribution.Simple | ||
2 | main = defaultMain | ||
diff --git a/axis-of-eval.cabal b/axis-of-eval.cabal new file mode 100644 index 0000000..2942f16 --- /dev/null +++ b/axis-of-eval.cabal | |||
@@ -0,0 +1,21 @@ | |||
1 | -- Initial axis-of-eval.cabal generated by cabal init. For further | ||
2 | -- documentation, see http://haskell.org/cabal/users-guide/ | ||
3 | |||
4 | name: axis-of-eval | ||
5 | version: 0.0.0.1 | ||
6 | -- synopsis: | ||
7 | -- description: | ||
8 | homepage: axis.childrenofmay.org | ||
9 | license: AllRightsReserved | ||
10 | license-file: LICENSE | ||
11 | author: Andrew Cady | ||
12 | maintainer: d@childrenofmay.org | ||
13 | -- copyright: | ||
14 | category: Sound | ||
15 | build-type: Simple | ||
16 | cabal-version: >=1.8 | ||
17 | |||
18 | executable axis-of-eval | ||
19 | -- main-is: | ||
20 | -- other-modules: | ||
21 | build-depends: base ==4.5.* \ No newline at end of file | ||
@@ -0,0 +1,36 @@ | |||
1 | import FRP.Netwire hiding (when) | ||
2 | import Prelude hiding ((.), id) | ||
3 | import Data.Time.Clock | ||
4 | import Control.Wire hiding (when) | ||
5 | import Control.Wire.Session | ||
6 | import Control.Monad | ||
7 | import qualified Graphics.UI.SDL as SDL | ||
8 | |||
9 | netwireIsCool :: (Monad m) => Wire (Timed NominalDiffTime ()) () m a String | ||
10 | netwireIsCool = | ||
11 | for 2.5 . pure "Once upon a time..." --> | ||
12 | for 3 . pure "... games were completely imperative..." --> | ||
13 | for 2 . pure "... but then..." --> | ||
14 | for 10 . (pure "Netwire 5! " <> anim) --> | ||
15 | netwireIsCool | ||
16 | |||
17 | where | ||
18 | anim = | ||
19 | holdFor 0.5 . periodic 1 . pure "Hoo..." <|> | ||
20 | pure "...ray!" | ||
21 | |||
22 | --main :: IO () | ||
23 | --main = testWire clockSession_ netwireIsCool | ||
24 | |||
25 | main = SDL.withInit [SDL.InitVideo, SDL.InitTimer, SDL.InitJoystick] $ do | ||
26 | loop clockSession_ netwireIsCool "" | ||
27 | where | ||
28 | loop s w x = do | ||
29 | (ds, s') <- stepSession s | ||
30 | (ex, w') <- stepWire w ds (Right x) | ||
31 | let x' = either (const "") id ex | ||
32 | Control.Monad.when (x /= x' && x /= "") $ putStrLn x | ||
33 | let framerate = 30 | ||
34 | let delay = 1000 `div` framerate - 1000 * (floor $ dtime ds) | ||
35 | SDL.delay (delay) | ||
36 | loop s' w' x' | ||