From 4d007f6802246c6411a2838e68e957c2b4d56d3d Mon Sep 17 00:00:00 2001 From: Joris Guyonvarch Date: Wed, 4 Mar 2015 23:27:59 +0100 Subject: Adapt the game to elm version 0.14.1 --- src/Display.elm | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'src/Display.elm') 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 -- cgit v1.2.3