From 9c0f90e501f407d21d497829fa2fd727fe0c1039 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Mon, 13 Jan 2014 22:46:03 -0500 Subject: Initial commit. --- axis.hs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 axis.hs (limited to 'axis.hs') diff --git a/axis.hs b/axis.hs new file mode 100644 index 0000000..b59a6f6 --- /dev/null +++ b/axis.hs @@ -0,0 +1,36 @@ +import FRP.Netwire hiding (when) +import Prelude hiding ((.), id) +import Data.Time.Clock +import Control.Wire hiding (when) +import Control.Wire.Session +import Control.Monad +import qualified Graphics.UI.SDL as SDL + +netwireIsCool :: (Monad m) => Wire (Timed NominalDiffTime ()) () m a String +netwireIsCool = + for 2.5 . pure "Once upon a time..." --> + for 3 . pure "... games were completely imperative..." --> + for 2 . pure "... but then..." --> + for 10 . (pure "Netwire 5! " <> anim) --> + netwireIsCool + + where + anim = + holdFor 0.5 . periodic 1 . pure "Hoo..." <|> + pure "...ray!" + +--main :: IO () +--main = testWire clockSession_ netwireIsCool + +main = SDL.withInit [SDL.InitVideo, SDL.InitTimer, SDL.InitJoystick] $ do + loop clockSession_ netwireIsCool "" + where + loop s w x = do + (ds, s') <- stepSession s + (ex, w') <- stepWire w ds (Right x) + let x' = either (const "") id ex + Control.Monad.when (x /= x' && x /= "") $ putStrLn x + let framerate = 30 + let delay = 1000 `div` framerate - 1000 * (floor $ dtime ds) + SDL.delay (delay) + loop s' w' x' -- cgit v1.2.3