From 5087ab54e110ff16ed7bf23f2ba9fa86042f9de9 Mon Sep 17 00:00:00 2001 From: John Shaver Date: Wed, 28 Jun 2017 15:02:51 -0700 Subject: [PATCH] Added the initial map (just a black background for now)w --- src/GLOBALS.elm | 10 +++++++--- src/Views/Body.elm | 2 +- src/Views/Map.elm | 29 +++++++++++++++++++++++++++++ src/Views/PlayArea.elm | 5 ++++- 4 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 src/Views/Map.elm diff --git a/src/GLOBALS.elm b/src/GLOBALS.elm index 6f53390..0083fac 100644 --- a/src/GLOBALS.elm +++ b/src/GLOBALS.elm @@ -2,12 +2,16 @@ module GLOBALS exposing (..) player_move_speed = - 120 + 150 character_radius = - 25 + 20 playAreaSize = - ( "500", "900" ) + ( 800, 880 ) + + +backgroundColor = + "black" diff --git a/src/Views/Body.elm b/src/Views/Body.elm index a1d4e0b..ac8d4da 100644 --- a/src/Views/Body.elm +++ b/src/Views/Body.elm @@ -14,5 +14,5 @@ view model = in div [] [ h1 [] [ text "ElmMan!" ] - , Views.PlayArea.render width height model + , Views.PlayArea.render (toString width) (toString height) model ] diff --git a/src/Views/Map.elm b/src/Views/Map.elm new file mode 100644 index 0000000..aa1ec33 --- /dev/null +++ b/src/Views/Map.elm @@ -0,0 +1,29 @@ +module Views.Map exposing (..) + +import GLOBALS exposing (backgroundColor, playAreaSize) +import Svg exposing (Svg, g, path) +import Svg.Attributes exposing (d, fill) +import Svg.Path exposing (pathToString, lineTo, subpath, startAt, closed) + + +render : Svg msg +render = + let + ( width, height ) = + playAreaSize + in + g [] + [ path + [ d <| + pathToString + [ subpath (startAt ( 0, 0 )) + closed + [ lineTo ( width, 0 ) + , lineTo ( width, height ) + , lineTo ( 0, height ) + ] + ] + , fill backgroundColor + ] + [] + ] diff --git a/src/Views/PlayArea.elm b/src/Views/PlayArea.elm index 69b07e4..4eab64a 100644 --- a/src/Views/PlayArea.elm +++ b/src/Views/PlayArea.elm @@ -5,10 +5,13 @@ import Svg exposing (svg) import Svg.Attributes exposing (width, height, viewBox) import Types exposing (Model) import Views.Player +import Views.Map render : String -> String -> Model -> Html msg render w h model = svg [ width w, height h, viewBox ("0 0 " ++ w ++ " " ++ h) ] - [ Views.Player.render model ] + [ Views.Map.render + , Views.Player.render model + ]