Skip to content

Commit

Permalink
make maze generation lazy
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Feb 25, 2022
1 parent 0fd2656 commit 9a00e91
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Main.elm
Expand Up @@ -12,6 +12,7 @@ import Html.Events.Extra.Touch as Touch exposing (Touch)
import Html.Styled as Html exposing (Html)
import Html.Styled.Attributes as HAttrs exposing (css)
import Html.Styled.Events as Events
import Html.Styled.Lazy as Lazy
import Json.Decode as Decode
import Maze exposing (Maze)
import Random
Expand Down Expand Up @@ -225,9 +226,7 @@ view model =
Route.Maze info ->
[ viewMazeControls
, viewCanvas model
, baseMaze info
|> Maze.generate (Random.initialSeed info.seed)
|> viewMaze
, Lazy.lazy carveAndView info
]

Route.NotFound ->
Expand All @@ -238,6 +237,13 @@ view model =
}


carveAndView : { width : Int, height : Int, shape : Route.MazeShape, seed : Int } -> Html msg
carveAndView params =
baseMaze params
|> Maze.generate (Random.initialSeed params.seed)
|> viewMaze


viewNewFormControls : Model -> Html Msg
viewNewFormControls model =
controlsBar
Expand Down

0 comments on commit 9a00e91

Please sign in to comment.