-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathPart2-4.elm
49 lines (38 loc) · 1.2 KB
/
Part2-4.elm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import Graphics.Element exposing (..)
import Time
import Window
import Color exposing (..)
import Graphics.Collage exposing (..)
import Graphics.Element exposing (..)
import Keyboard
import Text exposing (monospace, fromString)
import Time exposing (..)
import Window
import Signal exposing ((<~), (~), foldp, sampleOn)
import Debug exposing (log, watch)
type H = H
(gameWidth,gameHeight) = (600,400)
(halfWidth,halfHeight) = (300,200)
pongGreen = rgb 60 100 60
textGreen = rgb 160 200 160
-- Exercise 2.3
-- Static shapes are boring. Let's animate the shapes you created above by using the `orbit` functions
-- below.
-- Hint:
-- - look at the variants of map for Signals
time : Signal Float
time =
Signal.map (inSeconds << fst) (timestamp (fps 40))
orbit : Float -> (Float,Float) -> Form -> Form
orbit angle (x,y) form = move (x * sin angle, y * cos angle) form
orbitCCW : Float -> (Float,Float) -> Form -> Form
orbitCCW angle (x,y) form = move (x * cos angle, y * sin angle) form
scene3 : String -> Float -> (Int,Int) -> Element
scene3 txt angle (w,h) =
container w h middle <|
collage gameWidth gameHeight
[
H
]
main : Signal Element
main = (scene3 "hello") <~ H