Untitled
unknown
plain_text
2 years ago
1.6 kB
6
Indexable
type Map = [[Bloco]]
converte :: (Bloco,[Picture]) -> Picture
converte (P,pics) = pics !! 0
converte ((E),pics) = pics !! 1
converte ((A),pics) = pics !! 2
converte (V,pics) = Blank
drawMap :: (Map,[Picture]) -> (Int,Int) -> [Picture]
drawMap ([],_) _ = []
drawMap ((h:t),pics) (x,y) = (Translate 0 (fromIntegral(y*(-16))) (Pictures (drawLinha (h,pics) x))):(drawMap (t,pics) (x,y+1))
drawLinha :: ([Bloco],[Picture]) -> Int -> [Picture]
drawLinha ([],_) _ = []
drawLinha ((h:t),pics) x = (Translate (fromIntegral(x*16)) 0 (converte (h,pics))):(drawLinha (t,pics) (x+1))
bloco :: Picture
bloco = (Polygon [(0,0),(40,0),(40,40),(0,40)])
escada :: Picture
escada = (Polygon [(0,0),(40,0),(40,40),(0,40)])
mapDraw :: Map
mapDraw = [[P, P, P, P, P, P, P, P, P, P]--0
,[P, V, V, V, P, V, V, P, V, P]--1
,[P, P, P, P, P, P, P, P, P, P]--2
,[P, V, V, V, E, V, P, E, V, P]--3
,[P, V, V, V, E, V, V, E, V, P]--4
,[P, V, V, V, E, A, V, E, V, P]--5
,[P, P, P, P, P, P, P, P, P, P]
,[P, V, V, V, E, V, V, E, V, P]
,[P, V, P, P, P, P, P, P, V, P]
,[P, V, V, V, V, V, V, P, V, P]
,[P, P, P, P, P, P, P, P, P, P]]--6:l
bigMapPic :: [Picture] -> Picture
bigMapPic pics = translate (-300) 420 (scale 5 5 (pictures (drawMap (mapDraw,pics) (0,0))))
get_images :: IO [Picture]
get_images = do
p <- loadBMP "bloco.bmp"
e <- loadBMP "stair.bmp"
a <- loadBMP "wood.bmp"
let images = [p,e,a]
return images
main :: IO()
main = do
images <- get_images
display window white (bigMapPic images)Editor is loading...
Leave a Comment