Skip to content

Instantly share code, notes, and snippets.

@chribben
Created August 14, 2013 20:45
Show Gist options
  • Save chribben/6235395 to your computer and use it in GitHub Desktop.
Save chribben/6235395 to your computer and use it in GitHub Desktop.
BouncingRandomTetrisBrick
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