module View.Game ( gameView ) where import List import Graphics.Collage exposing (..) import Graphics.Element exposing (Element) import Color exposing (..) import Text exposing (..) import Text import Time exposing (Time) import Model.Vec2 exposing (Vec2) import Model.Player exposing (..) import Model.Game exposing (Game) import Model.Point exposing (..) import Model.Config exposing (..) import Model.Round exposing (..) import View.Round exposing (roundView) gameView : Game -> Element gameView game = let pointsForm color = List.map (pointForm game.time (configColor color)) (game.cloud.points color) |> group forms = [ boardForm game.boardSize , playerForm game.player , pointsForm White , pointsForm Black , scoreForm game.boardSize game.time game.rounds game.currentScore ] in collage (truncate game.boardSize.x) (truncate game.boardSize.y) forms boardForm : Vec2 -> Form boardForm boardSize = filled boardColor (rect boardSize.x boardSize.y) boardColor : Color boardColor = rgb 103 123 244 playerForm : Player -> Form playerForm player = let playerColor = configColor player.config in 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 configColor : Config -> Color configColor config = case config of White -> rgb 240 240 240 Black -> rgb 14 17 33 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 scoreForm : Vec2 -> Time -> List Round -> Int -> Form scoreForm boardSize currentRoundTime rounds score = let scorePos = { x = 0.0 , y = boardSize.y / 2 - 35 } in if currentRoundTime < 5000 then case List.head rounds of Just round -> textForm scorePos (roundView round) Nothing -> textForm scorePos (toString score) else textForm scorePos (toString score) textForm : Vec2 -> String -> Form textForm pos content = let textElement = fromString content |> Text.height 24 |> typeface ["calibri", "arial"] |> Text.color textColor |> bold in textElement |> text |> move (pos.x, pos.y) textColor : Color textColor = rgb 14 17 33