#1 Rendering of level
This commit is contained in:
parent
fb4bc5bb36
commit
55212c1440
10 changed files with 58 additions and 4 deletions
|
@ -5,6 +5,7 @@ import GHC.IO (unsafePerformIO)
|
|||
import Graphics.Gloss.Juicy (loadJuicyPNG)
|
||||
import Data.Maybe (fromJust)
|
||||
import Graphics.Gloss.Data.Picture (scale)
|
||||
import Graphics.Gloss.Data.Bitmap (BitmapData(..))
|
||||
|
||||
----------------------------- Constants ------------------------------
|
||||
|
||||
|
@ -28,6 +29,15 @@ allEntities = [
|
|||
("door", "door.png")
|
||||
]
|
||||
|
||||
allEnvironment :: [(String, FilePath)]
|
||||
allEnvironment = [
|
||||
("void", "void.png"),
|
||||
("tile", "tile.png"),
|
||||
("wall", "wall.png"),
|
||||
("entrance", "entrance.png"),
|
||||
("exit", "exit.png")
|
||||
]
|
||||
|
||||
allItems :: [(String, FilePath)]
|
||||
allItems = [
|
||||
("dagger", "dagger.png"),
|
||||
|
@ -39,7 +49,7 @@ library :: [(String, Picture)]
|
|||
library = unknown:entities ++ environment ++ gui ++ items
|
||||
where unknown = ("unkown", renderPNG (assetsFolder ++ unknownImage))
|
||||
entities = map (\(f, s) -> (f, renderPNG (assetsFolder ++ "entities/" ++ s))) allEntities
|
||||
environment = []
|
||||
environment = map (\(f, s) -> (f, renderPNG (assetsFolder ++ "environment/" ++ s))) allEnvironment
|
||||
gui = []
|
||||
items = map (\(f, s) -> (f, renderPNG (assetsFolder ++ "items/" ++ s))) allItems
|
||||
|
||||
|
@ -57,6 +67,7 @@ getRender id = get filtered
|
|||
get [] = snd $ head library
|
||||
get ((_, res):_) = res
|
||||
|
||||
-- Move a picture by game coordinates
|
||||
setRenderPos :: Int -> Int -> Picture -> Picture
|
||||
setRenderPos x y = translate floatX floatY
|
||||
where floatX = fromIntegral x * zoom * resolution
|
||||
|
|
Reference in a new issue