diff options
author | Joris Guyonvarch | 2015-03-07 18:46:47 +0100 |
---|---|---|
committer | Joris Guyonvarch | 2015-03-07 18:46:47 +0100 |
commit | 6c1f5e10631a3f66f4c85a45b6f28ffd366105c5 (patch) | |
tree | 624d833aa62ad8ce5ed172144ff69a2846d55154 /src/View | |
parent | ae14beca0452b59ead64b8cdd6544824d59a55dc (diff) |
Show best score in html layout
Diffstat (limited to 'src/View')
-rw-r--r-- | src/View/Game.elm | 29 | ||||
-rw-r--r-- | src/View/Page.elm | 11 |
2 files changed, 19 insertions, 21 deletions
diff --git a/src/View/Game.elm b/src/View/Game.elm index 25b519c..8e76b48 100644 --- a/src/View/Game.elm +++ b/src/View/Game.elm @@ -18,15 +18,15 @@ import Model.Board (boardSize) import Model.Config (..) gameView : Game -> Element -gameView {time, score, player, cloud, bestScore} = - 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 - ++ blackPointForms - ++ scoreForms score - ++ bestScoreForms bestScore +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) + forms = + boardForms + ++ playerForms game.player + ++ whitePointForms + ++ blackPointForms + ++ scoreForms game.currentScore in collage (truncate boardSize.x) (truncate boardSize.y) forms boardForms : List Form @@ -72,17 +72,6 @@ scoreForms score = scorePos = { x = 0.0, y = boardSize.y / 2 - 30 } in [textForm text scorePos centered] -bestScoreForms : Int -> List Form -bestScoreForms bestScore = - if(bestScore > 0) then - let text = "Record: " ++ (toString bestScore) - pos = - { x = -boardSize.x / 2 + 100 - , y = -boardSize.y / 2 + 30 - } - in [textForm text pos leftAligned] - else [] - textForm : String -> Vec2 -> (Text -> Element) -> Form textForm content pos alignment = let textElement = fromString content diff --git a/src/View/Page.elm b/src/View/Page.elm index 6d6c54d..4dd54b5 100644 --- a/src/View/Page.elm +++ b/src/View/Page.elm @@ -20,13 +20,22 @@ pageView game = [ h1 [] [ text "cAtchVoid" ] , div [ id "game" ] - [ fromElement << gameView <| game ] + [ fromElement <| gameView game ] , p [] [ text "Catch the points of your color, avoid the other points." ] , p [] [ text "Use the arrow keys to move and 'e' to change your color." ] + , ( if List.isEmpty game.scores + then + div [ class "bestScore" ] [] + else + let bestScore = List.maximum game.scores + in p + [ class "bestScore isDefined" ] + [ text <| "Best score: " ++ (toString bestScore) ] + ) , a [ href "https://github.com/guyonvarch/catchvoid" ] [ img |