on master help sign in
Rogue: put image-generation functions together
commit39b31c6593115dc2d9c861adbe0b3b90f65e9046 authorJonathan Daugherty <cygnus@foobox.com> dateFri 1 Aug 2014, 15:37 (12 years ago) parent051a6d9
1 file changed+8−4
test/Rogue.hs+8−4
test/Rogue.hs+8−4
@@ -76,10 +76,6 @@ addRoom levelWidth levelHeight geo (centerX, centerY) = do
7676 let room = [((x,y), EmptySpace) | x <- [xMin..xMax - 1], y <- [yMin..yMax - 1]]
7777 return (geo // room)
7878
79−imageForGeo :: LevelPiece -> Image
80−imageForGeo EmptySpace = char (defAttr `withBackColor` green) ' '
81−imageForGeo Rock = char defAttr 'X'
82−
8379pieceA, dumpA :: Attr
8480pieceA = defAttr `withForeColor` blue `withBackColor` green
8581dumpA = defAttr `withStyle` reverseVideo
@@ -132,6 +128,10 @@ updateDisplay = do
132128 vty <- ask
133129 liftIO $ update vty pic
134130
131+--
132+-- Image-generation functions
133+--
134+
135135worldImages :: Game [Image]
136136worldImages = do
137137 thePlayer <- gets player
@@ -139,6 +139,10 @@ worldImages = do
139139 let playerImage = translate (playerX thePlayer) (playerY thePlayer) (char pieceA '@')
140140 return [playerImage, levelGeoImage theLevel]
141141
142+imageForGeo :: LevelPiece -> Image
143+imageForGeo EmptySpace = char (defAttr `withBackColor` green) ' '
144+imageForGeo Rock = char defAttr 'X'
145+
142146buildGeoImage :: Geo -> Image
143147buildGeoImage geo =
144148 let (geoWidth, geoHeight) = snd $ bounds geo