Update rogue demo to translate the player rather than using spaces to center it to avoid layer opacity issues

This commit is contained in:
Jonathan Daugherty 2015-07-03 16:02:29 -07:00
parent 149ab2d58b
commit 32c82d0754
2 changed files with 7 additions and 2 deletions

View File

@ -216,4 +216,5 @@ executable brick-rogue
vty >= 5.2.9,
data-default,
array,
random
random,
lens

View File

@ -6,6 +6,7 @@ import Graphics.Vty
import Data.Array
import Control.Lens ((^.))
import Control.Applicative
import Control.Monad
@ -129,7 +130,10 @@ updateDisplay world = [ info, playerLayer, geoLayer ]
(px, py) = playerCoord $ player world
playerLoc = Location (px, py)
theLevel = level world
playerLayer = center $ raw (char pieceA '@')
playerLayer = Widget Fixed Fixed $ do
c <- getContext
render $ translateBy (Location (c^.availW `div` 2, c^.availH `div` 2)) $
raw $ char pieceA '@'
geoLayer = centerAbout playerLoc $ raw $ levelGeoImage theLevel
imageForGeo :: LevelPiece -> Image