on master help sign in
more silly hackery - expand the rouge game
58cf416Corey O'Connor
test/Rouge.hs+4−7
@@ -49,13 +49,10 @@ mkLevel _difficulty = do
49 level_height <- randomRIO (10,15)
49 level_height <- randomRIO (10,15)
50 start <- (,) <$> randomRIO (2, level_width-3) <*> randomRIO (2, level_height-3)
50 start <- (,) <$> randomRIO (2, level_width-3) <*> randomRIO (2, level_height-3)
51 end <- (,) <$> randomRIO (2, level_width-3) <*> randomRIO (2, level_height-3)
51 end <- (,) <$> randomRIO (2, level_width-3) <*> randomRIO (2, level_height-3)
52+ -- first the base geography: all rocks
52− let geo = array ((0,0), (level_width, level_height))
53+ let base_geo = array ((0,0), (level_width, level_height))
53− [((x,y),p) | x <- [0..level_width-1], y <- [0..level_height-1],
54+ [((x,y),Rock) | x <- [0..level_width-1], y <- [0..level_height-1]]
54− let p = if (x == 0 || x == level_width-1) || (y==0 || y==level_height-1)
55− then Rock
56− else EmptySpace
57− ]
58− return $ Level start end geo
55+ return $ Level start end base_geo
59
56
60image_for_geo EmptySpace = char (def_attr `with_back_color` green) ' '
57image_for_geo EmptySpace = char (def_attr `with_back_color` green) ' '
61image_for_geo Rock = char (def_attr `with_fore_color` white) 'X'
58image_for_geo Rock = char (def_attr `with_fore_color` white) 'X'