Created
February 27, 2015 05:39
-
-
Save brainrake/60fb413cf7c71d3139e9 to your computer and use it in GitHub Desktop.
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
import Color (..) | |
import Graphics.Collage (..) | |
import Graphics.Element (..) | |
import Time (fps, fpsWhen) | |
import Keyboard (isDown) | |
import Char (toCode) | |
import Signal (foldp,map2, (<~)) | |
import Text(asText) | |
import List (map, (::)) | |
(<--) = (<~) | |
infixr 4 <-- | |
notes = [ (0.0,1.0),(20.0,30.0),(40.0,60.0),(87.0,160.0) ] | |
f = foldp (+) 0 <| fps 30 | |
aDown = isDown <| toCode 'a' | |
aFps = fpsWhen 30 aDown | |
size = foldp (\x a -> if x == 0 then 0 else a + x) 0 aFps | |
size_reset = map2 (\x d -> if not d then 0 else x) size aDown | |
render_rect y (y1,y2) = filled black <| polygon [ (0.0,(y1-y)/10),(10.0,(y1-y)/10),(10.0,(y2-y)/10),(0.0,(y2-y)/10)] | |
render : Float -> List ( Float, Float ) -> Element | |
render f lf = collage 500 500 <| map (render_rect f) lf | |
fx (d1, f) (d2, a) = | |
if d1 && (not d2) | |
then (d1, (f, f)::a) | |
else if d1 && d2 then case a of | |
((a1,a2)::ass) -> (d1, (a1, f)::ass) | |
_ -> (d1, a) | |
else (d1, a) | |
main = map2 render f (snd <-- foldp fx (False, []) (map2 (,) aDown (foldp (+) 0 <| fps 30))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment