diff options
author | Joris Guyonvarch | 2015-03-04 23:27:59 +0100 |
---|---|---|
committer | Joris Guyonvarch | 2015-03-05 00:27:32 +0100 |
commit | 4d007f6802246c6411a2838e68e957c2b4d56d3d (patch) | |
tree | 70519a5a2d6825bf2b64f6a8950a003b2ff4f150 /src/Display.elm | |
parent | d37a301ed39bac823e0f2223b8d229b417e128c7 (diff) |
Adapt the game to elm version 0.14.1
Diffstat (limited to 'src/Display.elm')
-rw-r--r-- | src/Display.elm | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/Display.elm b/src/Display.elm index c52b9e3..acbc15e 100644 --- a/src/Display.elm +++ b/src/Display.elm @@ -1,5 +1,13 @@ module Display where +import List + +import Graphics.Collage (..) +import Graphics.Element (Element) +import Color (..) +import Text (..) +import Text + import Vec2 (..) import Player (..) import Game (Game) @@ -9,8 +17,8 @@ import Config (..) display : Game -> Element display {time, score, player, cloud, bestScore} = - let whitePointForms = map (pointForm time (configColor White)) (cloud.points White) - blackPointForms = map (pointForm time (configColor Black)) (cloud.points Black) + let whitePointForms = List.map (pointForm time (configColor White)) (cloud.points White) + blackPointForms = List.map (pointForm time (configColor Black)) (cloud.points Black) forms = boardForms ++ playerForms player ++ whitePointForms @@ -19,13 +27,13 @@ display {time, score, player, cloud, bestScore} = ++ bestScoreForms bestScore in collage (truncate boardSize.x) (truncate boardSize.y) forms -boardForms : [Form] +boardForms : List Form boardForms = [filled boardColor (rect boardSize.x boardSize.y)] boardColor : Color boardColor = rgb 103 123 244 -playerForms : Player -> [Form] +playerForms : Player -> List Form playerForms player = let playerColor = configColor player.config in [circleForm player.pos playerSize playerColor] @@ -56,16 +64,16 @@ circleForm pos size color = outlineColor : Color outlineColor = rgb 34 34 34 -scoreForms : Int -> [Form] +scoreForms : Int -> List Form scoreForms score = - let text = (show score) + let text = (toString score) scorePos = { x = 0.0, y = boardSize.y / 2 - 30 } in [textForm text scorePos centered] -bestScoreForms : Int -> [Form] +bestScoreForms : Int -> List Form bestScoreForms bestScore = if(bestScore > 0) then - let text = "Record: " ++ (show bestScore) + let text = "Record: " ++ (toString bestScore) pos = { x = -boardSize.x / 2 + 100 , y = -boardSize.y / 2 + 30 @@ -75,7 +83,7 @@ bestScoreForms bestScore = textForm : String -> Vec2 -> (Text -> Element) -> Form textForm content pos alignment = - let textElement = toText content + let textElement = fromString content |> Text.height 30 |> typeface ["calibri", "arial"] |> Text.color textColor |