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 Signal | |
import Mouse | |
cl = (clamp 100 200) <~ Mouse.x | |
reactiveCircle = (filled blue) <~ (circle <~ (toFloat <~ cl)) | |
main = lift (collage 300 300) (Signal.combine [reactiveCircle]) |
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
time = lift (inSeconds . fst) (timestamp (fps 40)) | |
a dy = let c = filled blue (circle 10) | |
in collage 300 300 | |
[c |> move (0, 100 * cos dy)] | |
b = lift a time | |
main = b |
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 | Square | |
rand a = Random.range 0 6 (constant a) | |
brick n = if | n == 0 -> Line | |
| n == 2 -> LeftSquiggle | |
| n == 3 -> RightSquiggle | |
| n == 4 -> RightStick | |
| n == 5 -> LeftStick | |
| otherwise -> Square | |
main = asText <~ (brick <~ (rand 1)) |
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) |
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 | |
import Mouse | |
import Keyboard | |
data Fruit = Apple | Orange | Banana | Melon | Guava | |
rand = Random.range 0 4 (Mouse.clicks) | |
fruit n = if | n == 0 -> Apple | |
| n == 1 -> Orange | |
| n == 2 -> Banana | |
| n == 3 -> Melon | |
| otherwise -> Guava |
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 Keyboard | |
keyToBool x = if x == 0 then False else True | |
sfx p = lift (\p -> p.x) p | |
signalX = sfx Keyboard.arrows | |
xArrowPulse = fpsWhen 10 (keyToBool <~ signalX) | |
main = lift asText xArrowPulse |
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 Mouse | |
import Window | |
-- Mouse.isDown is true whenever the left mouse button | |
-- is pressed down and false otherwise. | |
--MODEL | |
type Points = [(Int,Int)] | |
--UPDATE |
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 List | |
import Mouse | |
import Window | |
--MODEL | |
defaultBall = {x = 0, y = 0, v = toFloat 0, angle = toFloat 0} | |
--UPDATE | |
location t b = { b | x <- b.x - t * b.v * cos b.angle, | |
y <- b.y - t * b.v * sin b.angle } |
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 String | |
import Graphics.Input (Input, input) | |
import Graphics.Input.Field as Field | |
xaxis = segment (-150,-100) (150,-100) | |
yaxis = segment (-150,-100) (-150,100) | |
content : Input Field.Content | |
content = input Field.noContent | |
field = Field.field Field.defaultStyle content.handle id "Type here!" <~ content.signal |
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 Keyboard | |
import Window | |
import Graphics.Input (Input, input, button, dropDown) | |
import Graphics.Input.Field (Content, noContent, field, defaultStyle, Forward, Backward) | |
-- MODEL | |
data Direction = North | East | South | West | |
type Robot = {x:Int, y:Int, dir:Direction} | |
type Board = [(Int,Int)] | |
type Game = {robot:Robot, board:Board} |