#9 Added level selection render
This commit is contained in:
parent
0786a41006
commit
2055ef234e
17 changed files with 401 additions and 34 deletions
|
@ -1,6 +1,6 @@
|
|||
module RPGEngine.Render.Core where
|
||||
|
||||
import Graphics.Gloss ( Picture, translate )
|
||||
import Graphics.Gloss ( Picture, translate, pictures )
|
||||
import GHC.IO (unsafePerformIO)
|
||||
import Graphics.Gloss.Juicy (loadJuicyPNG)
|
||||
import Data.Maybe (fromJust)
|
||||
|
@ -21,7 +21,7 @@ assetsFolder :: FilePath
|
|||
assetsFolder = "assets/"
|
||||
|
||||
unknownImage :: FilePath
|
||||
unknownImage = "unkown.png"
|
||||
unknownImage = "unknown.png"
|
||||
|
||||
allEntities :: [(String, FilePath)]
|
||||
allEntities = [
|
||||
|
@ -32,6 +32,7 @@ allEntities = [
|
|||
allEnvironment :: [(String, FilePath)]
|
||||
allEnvironment = [
|
||||
("void", "void.png"),
|
||||
("overlay", "overlay.png"),
|
||||
("tile", "tile.png"),
|
||||
("wall", "wall.png"),
|
||||
("entrance", "entrance.png"),
|
||||
|
@ -47,7 +48,7 @@ allItems = [
|
|||
-- Map of all renders
|
||||
library :: [(String, Picture)]
|
||||
library = unknown:entities ++ environment ++ gui ++ items
|
||||
where unknown = ("unkown", renderPNG (assetsFolder ++ unknownImage))
|
||||
where unknown = ("unknown", renderPNG (assetsFolder ++ unknownImage))
|
||||
entities = map (\(f, s) -> (f, renderPNG (assetsFolder ++ "entities/" ++ s))) allEntities
|
||||
environment = map (\(f, s) -> (f, renderPNG (assetsFolder ++ "environment/" ++ s))) allEnvironment
|
||||
gui = []
|
||||
|
@ -71,4 +72,14 @@ getRender id = get filtered
|
|||
setRenderPos :: Int -> Int -> Picture -> Picture
|
||||
setRenderPos x y = translate floatX floatY
|
||||
where floatX = fromIntegral x * zoom * resolution
|
||||
floatY = fromIntegral y * zoom * resolution
|
||||
floatY = fromIntegral y * zoom * resolution
|
||||
|
||||
overlay :: Picture
|
||||
overlay = setRenderPos offX offY $ pictures voids
|
||||
where voids = [setRenderPos x y void | x <- [0 .. width], y <- [0 .. height]]
|
||||
void = getRender "overlay"
|
||||
intZoom = round zoom :: Int
|
||||
height = round $ 4320 / resolution / zoom
|
||||
width = round $ 7680 / resolution / zoom
|
||||
offX = negate (width `div` 2)
|
||||
offY = negate (height `div` 2)
|
Reference in a new issue