Created
August 14, 2013 20:45
-
-
Save chribben/6235395 to your computer and use it in GitHub Desktop.
BouncingRandomTetrisBrick
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 Random | |
data Brick = Line | LeftSquiggle | RightSquiggle | LeftStick | RightStick | Box | |
rand = Random.range 0 6 (constant 1) | |
brick n = if | n == 0 -> Line | |
| n == 2 -> LeftSquiggle | |
| n == 3 -> RightSquiggle | |
| n == 4 -> RightStick | |
| n == 5 -> LeftStick | |
| otherwise -> Box | |
brickText = asText <~ (brick <~ rand) | |
brickTextForm = toForm <~ brickText | |
time = lift (inSeconds . fst) (timestamp (fps 40)) | |
scene dy form = collage 300 300 [move (0, 100 * cos dy) form] | |
main = lift2 scene time brickTextForm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment