Skip to content

Commit

Permalink
Add effect start time
Browse files Browse the repository at this point in the history
  • Loading branch information
Miko Mynttinen committed Apr 2, 2016
1 parent d566670 commit aee4ae5
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions demo1.elm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Effect = Cornfield | Rotozoom | Hypnocorn | Plasma | Starfield | Chilicorn

type alias State =
{ effect : Effect
, effectStart : Float
, time : Float
, stars: Starfield.Stars
}
Expand All @@ -29,23 +30,30 @@ muzak =
initialState : State
initialState =
{ effect = Chilicorn
, effectStart = 0
, time = 0
, stars = Starfield.stars
}

updateState : Float -> State -> State
updateState time state =
let
effect = selectEffectTime (time / 1000)
effect = selectEffect (time / 1000)
effectStart =
if effect /= state.effect then
time
else
state.effectStart
in
{ state |
effect = effect,
effectStart = effectStart,
time = time,
stars = Starfield.update state.time state.stars
}

selectEffectTime : Float -> Effect
selectEffectTime t =
selectEffect : Float -> Effect
selectEffect t =
if t < 10 then
Cornfield
else if t < 20 then
Expand Down

0 comments on commit aee4ae5

Please sign in to comment.