@@ -1,3 +1,4 @@
1+{-# LANGUAGE TemplateHaskell #-}
12module Main where
23
34import Graphics.Vty
@@ -7,6 +8,7 @@ import qualified Data.ByteString as B
78import Data.Word
89
910import Control.Applicative
11+import Control.Lens hiding (Level)
1012import Control.Monad
1113import Control.Monad.RWS
1214import Control.Monad.Writer
@@ -46,7 +48,7 @@ main = do
4648 vty <- mkVty
4749 level_0 <- mkLevel 1
4850 let world_0 = World (Dude (fst $ start level_0) (snd $ start level_0)) level_0
49− (_final_world, ()) <- execRWST (play >> view) vty world_0
51+ (_final_world, ()) <- execRWST (play >> update_display) vty world_0
5052 shutdown vty
5153
5254mkLevel difficulty = do
@@ -82,7 +84,7 @@ pieceA = def_attr `with_fore_color` blue `with_back_color` green
8284dumpA = def_attr `with_style` reverse_video
8385
8486play = do
85− view
87+ update_display
8688 done <- process_event
8789 unless done play
8890
@@ -111,8 +113,8 @@ move_dude dx dy = do
111113 EmptySpace -> put $ world { dude = Dude x' y' }
112114 _ -> return ()
113115
114−view :: Game ()
115−view = do
116+update_display :: Game ()
117+update_display = do
116118 let info = string def_attr "Move with the arrows keys. Press ESC to exit."
117119 -- determine offsets to place the dude in the center of the level.
118120 DisplayRegion w h <- asks terminal >>= liftIO . display_bounds