Add blurring of lightmap (and refactoring)

This commit is contained in:
2021-05-01 02:28:04 +02:00
parent 9c0e4425da
commit 7711738b3b
33 changed files with 485 additions and 249 deletions
-36
View File
@@ -1,27 +1,21 @@
--{-# LANGUAGE Strict #-}
{-# LANGUAGE BangPatterns #-}
module Dodge.Base where
-- imports {{{
import Dodge.Data
import Dodge.Config.Data
import Geometry
import Picture
import Control.Lens
import Control.Monad.State
import Data.List
import Data.Function
import Data.Maybe
import Data.Bifunctor
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS
import qualified Data.Set as S
-- }}}
--
leftPad :: Int -> a -> [a] -> [a]
leftPad i x xs = reverse $ take i $ reverse (take i xs) ++ repeat x
@@ -743,36 +737,6 @@ nearestCrInFront p dir x w
crInPolygon :: Creature -> [Point2] -> Bool
crInPolygon cr xs = errorPointInPolygon 3 (_crPos cr) xs
{- | Uses a layer to set the depth.
-}
onLayer :: Layer -> Picture -> Picture
onLayer l = setDepth $ 1 - fromIntegral (levLayer l) / 100
{- | Set a depth according to a list of numbers.
Lists are lexicographically ordered if input values are always less than 100.
Higher numbers will get placed on top of lower numbers.
-}
onLayerL :: [Int] -> Picture -> Picture
onLayerL is = setDepth (1 - (sum $ zipWith (/) (map fromIntegral is) $ map (100 **) [1..]))
{- | For depth testing, set layer values.
-}
levLayer :: Layer -> Int
levLayer BgLayer = 20
levLayer PressPlateLayer = 45
levLayer CorpseLayer = 50
levLayer FlItLayer = 55
levLayer CrLayer = 60
levLayer WlLayer = 74
levLayer GloomLayer = 67
levLayer UPtLayer = 70
levLayer PtLayer = 72
levLayer HPtLayer = 73
levLayer ShadowLayer = 75
levLayer LabelLayer = 80
levLayer InvLayer = 85
levLayer MenuDepth = 90
{- | Transform coordinates from world position to normalised screen coordinates.
-}
worldPosToScreen :: World -> Point2 -> Point2