From 2e21f02bff991c16c660504beb85957d5b2c872f Mon Sep 17 00:00:00 2001 From: Chris Hendrix and Yulia Tolskaya Date: Thu, 18 Jun 2015 15:48:57 -0700 Subject: [PATCH] Change view code to use elements --- src/Rogue/View.elm | 60 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/src/Rogue/View.elm b/src/Rogue/View.elm index 16fd9c6..0e666d7 100644 --- a/src/Rogue/View.elm +++ b/src/Rogue/View.elm @@ -10,24 +10,68 @@ import Array exposing (..) import Rogue.Model exposing (..) view : Game -> Element -view g = leftAligned (Text.monospace (Text.fromString (toString g.gameMap))) +view g = viewGameMap g.gameMap -toString : GameMap -> String -toString {board,start,currentPlayerLocation} = +viewGameMap : GameMap -> Element +viewGameMap {board,start,currentPlayerLocation} = let rowifier = (\row -> Array.map (\cell -> - if | isAt currentPlayerLocation cell -> "@" - | not <| isOpen cell -> "#" - | otherwise -> "." + if | isAt currentPlayerLocation cell -> person + | not <| isOpen cell -> barrier + | otherwise -> open ) row |> toList - |> join "" + |> flow right ) in Array.map rowifier board |> toList - |> join "\n" \ No newline at end of file + |> flow down + + +txt str = + Text.fromString str + |> Text.monospace + |> centered + +person = + txt "@" + |> standardize + +barrier = + square 16 + |> filled red + |> (\sq -> collage 16 16 [sq]) + |> standardize + +open = + txt "." + |> standardize + +standardize : Element -> Element +standardize el = + el + |> container 16 16 middle + +--toString = +-- let +-- rowifier = +-- (\row -> +-- Array.map +-- (\cell -> +-- if | isAt currentPlayerLocation cell -> "@" +-- | not <| isOpen cell -> "#" +-- | otherwise -> "." +-- ) +-- row +-- |> toList +-- |> join "" +-- ) +-- in +-- Array.map rowifier board +-- |> toList +-- |> join "\n" \ No newline at end of file