module Display where import Vec2 (..) import Player (..) import Game (Game) import Point (..) import Board (boardSize) display : Game -> Element display {time, score, player, cloud, bestScore} = let greenPointForms = map (pointForm time greenPointColor) cloud.greenPoints redPointForms = map (pointForm time redPointColor) cloud.redPoints forms = boardForms ++ playerForms player ++ greenPointForms ++ redPointForms ++ scoreForms score ++ bestScoreForms bestScore in collage (truncate boardSize.x) (truncate boardSize.y) forms boardForms : [Form] boardForms = [filled boardColor (rect boardSize.x boardSize.y)] boardColor : Color boardColor = rgb 17 17 17 playerForms : Player -> [Form] playerForms player = [circleForm player.pos playerSize playerColor] playerColor : Color playerColor = rgb 224 224 224 pointForm : Float -> Color -> Point -> Form pointForm time color point = let pos = pointMove point time in circleForm pos pointSize color greenPointColor : Color greenPointColor = rgb 34 85 34 redPointColor : Color redPointColor = rgb 170 0 0 circleForm : Vec2 -> Float -> Color -> Form circleForm pos size color = let outline = circle size |> filled outlineColor inside = circle (size - 1) |> filled color in group [outline, inside] |> move (pos.x, pos.y) outlineColor : Color outlineColor = rgb 34 34 34 scoreForms : Int -> [Form] scoreForms score = let text = (show score) scorePos = { x = 0.0, y = boardSize.y / 2 - 30 } in [textForm text scorePos centered] bestScoreForms : Int -> [Form] bestScoreForms bestScore = if(bestScore > 0) then let text = "Record: " ++ (show bestScore) pos = { x = boardSize.x / 2 - 65 , y = -boardSize.y / 2 + 30 } in [textForm text pos rightAligned] else [] textForm : String -> Vec2 -> (Text -> Element) -> Form textForm content pos alignment = let textElement = toText content |> typeface ["calibri", "arial"] |> Text.color textColor |> bold |> alignment in textElement |> toForm |> move (pos.x, pos.y) textColor : Color textColor = rgb 224 224 224