From 8714c3befcf3f9923cf72e8d992ba6d963c0e6e7 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 4 Sep 2016 15:52:17 +0200 Subject: Upgrade to elm 0.17.1 --- src/View/Game.elm | 208 ----------------------------------------------------- src/View/Round.elm | 4 +- src/View/Time.elm | 4 +- 3 files changed, 4 insertions(+), 212 deletions(-) delete mode 100644 src/View/Game.elm (limited to 'src/View') diff --git a/src/View/Game.elm b/src/View/Game.elm deleted file mode 100644 index 2bef2ae..0000000 --- a/src/View/Game.elm +++ /dev/null @@ -1,208 +0,0 @@ -module View.Game - ( renderGame - ) where - -import Html exposing (Html) -import Svg exposing (..) -import Svg.Attributes exposing (..) -import List - -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 Model.Level exposing (..) -import Model.Color exposing (htmlOutput) - -import View.Round exposing (roundView) - -renderGame : Game -> Html -renderGame game = - let renderPoints config = List.map (renderPoint game.boardSize game.elapsedTime config) (game.cloud.points config) - in svg - [ width "100%" - , height "100%" - , Svg.Attributes.style ("background-color: " ++ backgroundColor ++ ";") - , viewBox ("0 0 " ++ (toString game.boardSize.x) ++ " " ++ (toString (game.boardSize.y + headerHeight))) - ] - [ renderBoard game.currentScore - , renderPlayer game.boardSize game.player (getPlayerSize game.currentScore) - , g [] (renderPoints White) - , g [] (renderPoints Black) - , renderScore game.boardSize game.elapsedTime game.rounds game.currentScore - , hideNewPoints game.boardSize - , renderHeader game - ] - -headerHeight : Float -headerHeight = 115 - -renderHeader : Game -> Svg -renderHeader game = - g - [] - [ rect - [ width "100%" - , height (toString headerHeight) - , fill "#1B203F" - ] - [] - , text' - [ x "10" - , y "45" - , fontSize "36" - , fill "white" - , fontWeight "bold" - ] - [ text "cAtchVoid" ] - , text' - [ fill "white" - , fontSize "12" - , fontStyle "italic" - ] - [ tspan - [ x (toString (game.boardSize.x / 2)) - , y "75" - , textAnchor "middle" - ] - [ text "Catch the points of your color, avoid the other points." ] - , tspan - [ x (toString (game.boardSize.x / 2)) - , y "92" - , textAnchor "middle" - ] - [ text "Use the arrow keys to move and 'e' to change your color." ] - ] - , ( case maybeBestRound game.rounds of - Nothing -> - text "" - Just bestRound -> - text' - [ fill "yellow" - , x "355" - , y "38" - , fontSize "13" - ] - [ tspan - [ textAnchor "middle" ] - [ text ("Top: " ++ roundView bestRound) ] - ] - ) - ] - -backgroundColor : String -backgroundColor = "#1B203F" - -renderBoard : Int -> Svg -renderBoard currentScore = - rect - [ y (toString headerHeight) - , width "100%" - , height "100%" - , fill (htmlOutput (progressiveColor currentScore)) - ] - [] - -renderPlayer : Vec2 -> Player -> Float -> Svg -renderPlayer boardSize player playerSize = - renderCircle boardSize player.pos playerSize (playerColor player.config) - -playerColor : Config -> String -playerColor config = - case config of - White -> "#F0F0F0" - Black -> "#0E1121" - -renderPoint : Vec2 -> Float -> Config -> Point -> Svg -renderPoint boardSize elapsedTime config point = - let pos = pointMove point elapsedTime - in renderCircle boardSize pos pointSize (playerColor config) - -pointColor : Config -> String -pointColor config = - case config of - White -> "white" - Black -> "black" - -renderCircle : Vec2 -> Vec2 -> Float -> String -> Svg -renderCircle boardSize pos size color = - circle - [ cx (toString (pos.x + boardSize.x / 2)) - , cy (toString (-1 * pos.y + boardSize.y / 2 + headerHeight)) - , r (toString size) - , fill color - ] - [] - -renderScore : Vec2 -> Time -> List Round -> Int -> Svg -renderScore boardSize elapsedTime rounds score = - let scorePos = - { x = 0.0 - , y = boardSize.y / 2 - 35 - } - scoreText = "L" ++ (toString << currentLevelNumber <| score) ++ " - " ++ (toString score) - in if elapsedTime < 5000 - then - case List.head rounds of - Just round -> - renderText boardSize scorePos (roundView round) - Nothing -> - renderText boardSize scorePos scoreText - else - renderText boardSize scorePos scoreText - -renderText : Vec2 -> Vec2 -> String -> Svg -renderText boardSize pos content = - text' - [ x (toString (pos.x + boardSize.x / 2)) - , y (toString (-1 * pos.y + boardSize.y / 2 + headerHeight)) - , fontFamily "calibri" - , fontSize "24" - , color "#0E1121" - , fontWeight "bold" - ] - [ tspan - [ textAnchor "middle" ] - [ text content ] - ] - -hideNewPoints : Vec2 -> Svg -hideNewPoints boardSize = - let size = - (pointAwayDist boardSize) + pointSize - (Basics.max boardSize.x boardSize.y) / 2 - |> toString - in g - [] - [ rect - [ x ("-" ++ size) - , width size - , height "100%" - , fill backgroundColor - ] - [] - , rect - [ x (toString boardSize.x) - , width size - , height "100%" - , fill backgroundColor - ] - [] - , rect - [ y ("-" ++ size) - , width "100%" - , height size - , fill backgroundColor - ] - [] - , rect - [ y (toString (boardSize.y + headerHeight)) - , width "100%" - , height size - , fill backgroundColor - ] - [] - ] diff --git a/src/View/Round.elm b/src/View/Round.elm index 2648aa8..a3f34e2 100644 --- a/src/View/Round.elm +++ b/src/View/Round.elm @@ -1,6 +1,6 @@ -module View.Round +module View.Round exposing ( roundView - ) where + ) import Model.Round exposing (..) diff --git a/src/View/Time.elm b/src/View/Time.elm index e6cfad6..6e6d261 100644 --- a/src/View/Time.elm +++ b/src/View/Time.elm @@ -1,6 +1,6 @@ -module View.Time +module View.Time exposing ( timeView - ) where + ) import Time exposing (Time) -- cgit v1.2.3