diff options
Diffstat (limited to 'src/View/Game.elm')
-rw-r--r-- | src/View/Game.elm | 57 |
1 files changed, 36 insertions, 21 deletions
diff --git a/src/View/Game.elm b/src/View/Game.elm index c9c58ff..ad0e9ea 100644 --- a/src/View/Game.elm +++ b/src/View/Game.elm @@ -9,35 +9,42 @@ import Graphics.Element (Element) import Color (..) import Text (..) import Text +import Time (Time) import Model.Vec2 (Vec2) import Model.Player (..) import Model.Game (Game) import Model.Point (..) import Model.Config (..) +import Model.Round (..) + +import View.Round (roundView) gameView : Game -> Element gameView game = - let whitePointForms = List.map (pointForm game.time (configColor White)) (game.cloud.points White) - blackPointForms = List.map (pointForm game.time (configColor Black)) (game.cloud.points Black) + let pointsForm color = + List.map (pointForm game.time (configColor color)) (game.cloud.points color) + |> group forms = - boardForms game.boardSize - ++ playerForms game.player - ++ whitePointForms - ++ blackPointForms - ++ scoreForms game.boardSize game.currentScore + [ 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 -boardForms : Vec2 -> List Form -boardForms boardSize = [filled boardColor (rect boardSize.x boardSize.y)] +boardForm : Vec2 -> Form +boardForm boardSize = + filled boardColor (rect boardSize.x boardSize.y) boardColor : Color boardColor = rgb 103 123 244 -playerForms : Player -> List Form -playerForms player = +playerForm : Player -> Form +playerForm player = let playerColor = configColor player.config - in [circleForm player.pos playerSize playerColor] + in circleForm player.pos playerSize playerColor playerColor : Color playerColor = rgb 224 224 224 @@ -65,20 +72,28 @@ circleForm pos size color = outlineColor : Color outlineColor = rgb 34 34 34 -scoreForms : Vec2 -> Int -> List Form -scoreForms boardSize score = - let text = (toString score) - scorePos = { x = 0.0, y = boardSize.y / 2 - 35 } - in [textForm text scorePos centered] +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 && (not (List.isEmpty rounds)) + then + List.head rounds + |> roundView + |> textForm scorePos + else + textForm scorePos (toString score) -textForm : String -> Vec2 -> (Text -> Element) -> Form -textForm content pos alignment = +textForm : Vec2 -> String -> Form +textForm pos content = let textElement = fromString content - |> Text.height 30 + |> Text.height 24 |> typeface ["calibri", "arial"] |> Text.color textColor |> bold - |> alignment + |> centered in textElement |> toForm |> move (pos.x, pos.y) |