Remove old layer code

This commit is contained in:
2022-04-10 10:32:55 +01:00
parent 2da4098d41
commit edd82fb3ac
17 changed files with 54 additions and 53 deletions
+1 -2
View File
@@ -42,7 +42,6 @@ import Dodge.Creature.State
import Dodge.Creature.Picture import Dodge.Creature.Picture
--import Dodge.Creature.ChooseTarget --import Dodge.Creature.ChooseTarget
--import Dodge.Item --import Dodge.Item
import Dodge.Picture.Layer
import Picture import Picture
import Geometry.Data import Geometry.Data
import qualified IntMapHelp as IM import qualified IntMapHelp as IM
@@ -155,7 +154,7 @@ startCr = defaultCreature
, _crHP = 1000 , _crHP = 1000
, _crMaxHP = 1500 , _crMaxHP = 1500
, _crInv = startInventory , _crInv = startInventory
, _crCorpse = onLayer CorpseLayer , _crCorpse = setDepth 5
$ color (greyN 0.5) $ pictures [color (greyN 0.8) $ circleSolid 10, circLine 10] $ color (greyN 0.5) $ pictures [color (greyN 0.8) $ circleSolid 10, circLine 10]
, _crFaction = PlayerFaction , _crFaction = PlayerFaction
, _crMvType = MvWalking yourDefaultSpeed , _crMvType = MvWalking yourDefaultSpeed
+1 -2
View File
@@ -10,7 +10,6 @@ import Dodge.Creature.ReaderUpdate
import Dodge.Creature.Action import Dodge.Creature.Action
import Dodge.Creature.Perception import Dodge.Creature.Perception
import Dodge.Item.Consumable import Dodge.Item.Consumable
import Dodge.Picture.Layer
import Dodge.SoundLogic import Dodge.SoundLogic
--import Geometry --import Geometry
import Picture import Picture
@@ -27,7 +26,7 @@ smallChaseCrit = chaseCrit
, _crRad = 4 , _crRad = 4
, _crPict = basicCrPict green , _crPict = basicCrPict green
, _crInv = IM.fromList [(0,medkit 200)] , _crInv = IM.fromList [(0,medkit 200)]
, _crCorpse = onLayer CorpseLayer $ color (greyN 0.5) $ circleSolid 4 , _crCorpse = setDepth 5 $ color (greyN 0.5) $ circleSolid 4
} }
chaseCrit :: Creature chaseCrit :: Creature
chaseCrit = defaultCreature chaseCrit = defaultCreature
+1 -2
View File
@@ -12,7 +12,6 @@ import Dodge.Creature.Lamp
import Dodge.WorldEvent.Explosion import Dodge.WorldEvent.Explosion
import Dodge.Creature.Picture import Dodge.Creature.Picture
--import Dodge.Creature.Stance.Data --import Dodge.Creature.Stance.Data
import Dodge.Picture.Layer
import Dodge.Particle.Spark import Dodge.Particle.Spark
import Dodge.Default import Dodge.Default
import Dodge.Creature.State import Dodge.Creature.State
@@ -32,7 +31,7 @@ barrel :: Creature
barrel = defaultInanimate barrel = defaultInanimate
{ _crUpdate = updateBarrel { _crUpdate = updateBarrel
, _crHP = 500 , _crHP = 500
, _crPict = picAtCrPos $ onLayer CrLayer $ pictures , _crPict = picAtCrPos $ setDepth 20 $ pictures
[ color orange $ circleSolid 10 [ color orange $ circleSolid 10
, setDepth 0.049 . color (greyN 0.5) $ circleSolid 8 , setDepth 0.049 . color (greyN 0.5) $ circleSolid 8
, color (greyN 0.5) $ circleSolid 8 , color (greyN 0.5) $ circleSolid 8
+1 -2
View File
@@ -11,7 +11,6 @@ import Dodge.Creature.ReaderUpdate
import Dodge.Creature.Perception import Dodge.Creature.Perception
--import Dodge.Creature.Impulse --import Dodge.Creature.Impulse
--import Dodge.Creature.State --import Dodge.Creature.State
import Dodge.Picture.Layer
import Picture import Picture
import Control.Lens import Control.Lens
@@ -32,7 +31,7 @@ swarmCrit = defaultCreature
, _crRad = 2 , _crRad = 2
, _crMass = 2 , _crMass = 2
, _crPict = basicCrPict yellow , _crPict = basicCrPict yellow
, _crCorpse = onLayer CorpseLayer $ color (greyN 0.5) $ circleSolid 2 , _crCorpse = setDepth 5 $ color (greyN 0.5) $ circleSolid 2
, _crFaction = ColorFaction yellow , _crFaction = ColorFaction yellow
, _crMeleeCooldown = 0 , _crMeleeCooldown = 0
} }
+2 -3
View File
@@ -1,6 +1,5 @@
module Dodge.Debug where module Dodge.Debug where
import Dodge.Data import Dodge.Data
import Dodge.Picture.Layer
import Dodge.Zone import Dodge.Zone
import Dodge.Base import Dodge.Base
import Geometry.Zone import Geometry.Zone
@@ -21,7 +20,7 @@ drawCircleAtForCol p t col w = w & props %~
{ _pjPos = p { _pjPos = p
, _pjStartPos = p , _pjStartPos = p
, _pjVel = V2 0 0 , _pjVel = V2 0 0
, _prDraw = \_ -> (,) mempty $ onLayer PtLayer $ uncurryV translate p $ color col $ circleSolid 20 , _prDraw = \_ -> (,) mempty $ setDepth 20 $ uncurryV translate p $ color col $ circleSolid 20
, _pjID = k , _pjID = k
, _pjUpdate = \_ -> pjTimerF t k , _pjUpdate = \_ -> pjTimerF t k
} }
@@ -34,7 +33,7 @@ drawLineForCol ps t col w = w & props %~
{ _pjPos = head ps { _pjPos = head ps
, _pjStartPos = head ps , _pjStartPos = head ps
, _pjVel = V2 0 0 , _pjVel = V2 0 0
, _prDraw = \_ -> (,) mempty $ onLayer PtLayer $ color col $ thickLine 5 ps , _prDraw = \_ -> (,) mempty $ setDepth 20 $ color col $ thickLine 5 ps
, _pjID = k , _pjID = k
, _pjUpdate = \_ -> pjTimerF t k , _pjUpdate = \_ -> pjTimerF t k
} }
+2 -3
View File
@@ -6,7 +6,6 @@ import Dodge.Data
import Dodge.RoomLink import Dodge.RoomLink
--import Dodge.Base --import Dodge.Base
import Dodge.LevelGen.Data import Dodge.LevelGen.Data
import Dodge.Picture.Layer
import Picture import Picture
import qualified IntMapHelp as IM import qualified IntMapHelp as IM
import Geometry.Data import Geometry.Data
@@ -26,11 +25,11 @@ roomLinkDecorations :: Room -> Picture
roomLinkDecorations rm = pictures . map (linkDecoration . lnkPosDir) $ _rmLinks rm roomLinkDecorations rm = pictures . map (linkDecoration . lnkPosDir) $ _rmLinks rm
linkDecoration :: (Point2,Float) -> Picture linkDecoration :: (Point2,Float) -> Picture
linkDecoration (p,a) = setLayer 1 . onLayer DebugLayer . color red $ line [p, p +.+ 20 *.* unitVectorAtAngle (a - pi/2)] linkDecoration (p,a) = setLayer 1 . setDepth 50 . color red $ line [p, p +.+ 20 *.* unitVectorAtAngle (a - pi/2)]
roomPolyDecorations :: Room -> Picture roomPolyDecorations :: Room -> Picture
roomPolyDecorations rm = pictures . map polyWireFrame $ _rmPolys rm roomPolyDecorations rm = pictures . map polyWireFrame $ _rmPolys rm
polyWireFrame :: [Point2] -> Picture polyWireFrame :: [Point2] -> Picture
polyWireFrame (x:xs) = setLayer 1 . onLayer DebugLayer . color green $ line $ (x:xs) ++ [x] polyWireFrame (x:xs) = setLayer 1 . setDepth 50 . color green $ line $ (x:xs) ++ [x]
polyWireFrame _ = undefined polyWireFrame _ = undefined
+2 -2
View File
@@ -44,7 +44,7 @@ defaultCreature = Creature
, _crInvEquipped = mempty , _crInvEquipped = mempty
, _crLeftInvSel = Nothing , _crLeftInvSel = Nothing
, _crState = defaultState , _crState = defaultState
, _crCorpse = setLayer 0 $ onLayer CorpseLayer $ color (greyN 0.5) $ circleSolid 10 , _crCorpse = setLayer 0 $ setDepth 5 $ color (greyN 0.5) $ circleSolid 10
, _crApplyDamage = defaultApplyDamage , _crApplyDamage = defaultApplyDamage
, _crStance = Stance , _crStance = Stance
{_carriage=Walking 0 WasLeftForward {_carriage=Walking 0 WasLeftForward
@@ -245,7 +245,7 @@ defaultPT = Projectile
} }
defaultPP :: PressPlate defaultPP :: PressPlate
defaultPP = PressPlate defaultPP = PressPlate
{ _ppPict = onLayer PressPlateLayer . color (dim . dim $ bright blue) $ circleSolid 5 { _ppPict = setDepth 1 . color (dim . dim $ bright blue) $ circleSolid 5
, _ppPos = V2 0 0 , _ppPos = V2 0 0
, _ppRot = 0 , _ppRot = 0
, _ppEvent = const id , _ppEvent = const id
+3 -3
View File
@@ -43,7 +43,7 @@ flameShield :: Item
flameShield = defaultEquipment flameShield = defaultEquipment
{ _itType = FLAMESHIELD { _itType = FLAMESHIELD
, _itName = "FLAMESHIELD" , _itName = "FLAMESHIELD"
, _itEquipPict = \cr _ -> (,) emptySH $ onLayer CrLayer $ pictures [color cyan $ circle (_crRad cr+2)] , _itEquipPict = \cr _ -> (,) emptySH $ setDepth 20 $ pictures [color cyan $ circle (_crRad cr+2)]
, _itID = Nothing , _itID = Nothing
} }
{- | Slows you down, blocks forward projectiles. -} {- | Slows you down, blocks forward projectiles. -}
@@ -55,7 +55,7 @@ frontArmour = defaultEquipment
-- [color (greyN 0.1) $ thickArc 0 (pi/2) 10 5 -- [color (greyN 0.1) $ thickArc 0 (pi/2) 10 5
-- ,color (greyN 0.1) $ thickArc (3*pi/2) (2*pi) 10 5 -- ,color (greyN 0.1) $ thickArc (3*pi/2) (2*pi) 10 5
-- ] -- ]
, _itEquipPict = \_ _ -> (,) emptySH $ onLayer CrLayer $ pictures , _itEquipPict = \_ _ -> (,) emptySH $ setDepth 20 $ pictures
[color (greyN 0.1) $ thickArc 0 (pi/2) 10 5 [color (greyN 0.1) $ thickArc 0 (pi/2) 10 5
,color (greyN 0.1) $ thickArc (3*pi/2) (2*pi) 10 5 ,color (greyN 0.1) $ thickArc (3*pi/2) (2*pi) 10 5
] ]
@@ -166,7 +166,7 @@ jetPack :: Item
jetPack = defaultEquipment jetPack = defaultEquipment
{ _itType = JETPACK { _itType = JETPACK
, _itName = "JETPACK" , _itName = "JETPACK"
, _itEquipPict = \_ _ -> (,) emptySH $ onLayer CrLayer , _itEquipPict = \_ _ -> (,) emptySH $ setDepth 20
$ pictures [color yellow $ polygon $ rectNSEW 5 (-5) (-3) (-11) ] $ pictures [color yellow $ polygon $ rectNSEW 5 (-5) (-3) (-11) ]
, _itEffect = NoItEffect , _itEffect = NoItEffect
, _itID = Nothing , _itID = Nothing
+1 -1
View File
@@ -81,7 +81,7 @@ updateLinearShockwave pj w
t = _pjTimer pj t = _pjTimer pj
drawBoostShockwave :: Prop -> SPic drawBoostShockwave :: Prop -> SPic
drawBoostShockwave pj = (,) mempty $ setLayer 1 $ onLayer UPtLayer $ pictures $ drawBoostShockwave pj = (,) mempty $ setLayer 1 $ setDepth 20 $ pictures $
theArc ++ theArc ++
[ lineCol $ zip (reverse lps) $ map (`withAlpha` white) [0,0.05..] [ lineCol $ zip (reverse lps) $ map (`withAlpha` white) [0,0.05..]
, lineCol $ zip (reverse rps) $ map (`withAlpha` white) [0,0.05..] , lineCol $ zip (reverse rps) $ map (`withAlpha` white) [0,0.05..]
+1 -2
View File
@@ -5,7 +5,6 @@ module Dodge.Item.Weapon.Decoration
( makeLaserScope ( makeLaserScope
) where ) where
import Dodge.Data import Dodge.Data
import Dodge.Picture.Layer
import Geometry.Data import Geometry.Data
import Picture import Picture
@@ -16,7 +15,7 @@ makeLaserScope
-> Float -- ^ Fraction of red/green -> Float -- ^ Fraction of red/green
-> Particle -> Particle
makeLaserScope p ep relFrac = Particle makeLaserScope p ep relFrac = Particle
{_ptDraw = const $ setLayer 1 $ onLayer PtLayer $ pictures {_ptDraw = const $ setLayer 1 $ setDepth 20 $ pictures
[lineAlphaThick 0.5 0.5 [lineAlphaThick 0.5 0.5
,lineAlphaThick 0.2 1.5 ,lineAlphaThick 0.2 1.5
,lineAlphaThick 0.1 2 ,lineAlphaThick 0.1 2
+2 -3
View File
@@ -18,7 +18,6 @@ import Dodge.Base
import Dodge.Item.Weapon.UseEffect import Dodge.Item.Weapon.UseEffect
import Dodge.Item.Weapon.LaserPath import Dodge.Item.Weapon.LaserPath
--import Dodge.Item.Attachment.Data --import Dodge.Item.Attachment.Data
import Dodge.Picture.Layer
import Dodge.Creature.Test import Dodge.Creature.Test
import Dodge.WorldEvent.HelperParticle import Dodge.WorldEvent.HelperParticle
import Picture import Picture
@@ -76,7 +75,7 @@ targetCursor = defaultTargeting
targetSimpleDraw :: Int -> Item -> Creature -> World -> Picture targetSimpleDraw :: Int -> Item -> Creature -> World -> Picture
targetSimpleDraw _ it _ w = fromMaybe mempty $ do targetSimpleDraw _ it _ w = fromMaybe mempty $ do
mwp <- it ^? itTargeting . tgPos . _Just mwp <- it ^? itTargeting . tgPos . _Just
return $ setLayer 5 $ color red $ onLayer InvLayer $ uncurryV translate mwp return $ setLayer 4 $ color red $ setDepth 50 $ uncurryV translate mwp
$ rotate (_cameraRot w) $ rotate (_cameraRot w)
$ pictures $ pictures
[line [V2 x x, V2 (-x) (-x)] [line [V2 x x, V2 (-x) (-x)]
@@ -88,7 +87,7 @@ targetSimpleDraw _ it _ w = fromMaybe mempty $ do
targetRBCreatureDraw :: Int -> Item -> Creature -> World -> Picture targetRBCreatureDraw :: Int -> Item -> Creature -> World -> Picture
targetRBCreatureDraw _ it _ w = fromMaybe mempty $ do targetRBCreatureDraw _ it _ w = fromMaybe mempty $ do
mwp <- it ^? itTargeting . tgPos . _Just mwp <- it ^? itTargeting . tgPos . _Just
return $ setLayer 5 $ color thecolor $ onLayer InvLayer $ uncurryV translate mwp return $ setLayer 5 $ color thecolor $ setDepth 50 $ uncurryV translate mwp
$ rotate (_cameraRot w) $ rotate (_cameraRot w)
$ pictures $ pictures
[line [V2 x x, V2 (-x) (-x)] [line [V2 x x, V2 (-x) (-x)]
+1 -2
View File
@@ -1,6 +1,5 @@
module Dodge.Item.Weapon.Grenade where module Dodge.Item.Weapon.Grenade where
import Dodge.Data import Dodge.Data
import Dodge.Picture.Layer
import Dodge.WorldEvent.Explosion import Dodge.WorldEvent.Explosion
--import Dodge.Item.Weapon.TriggerType --import Dodge.Item.Weapon.TriggerType
import Dodge.Item.Weapon.Remote import Dodge.Item.Weapon.Remote
@@ -193,7 +192,7 @@ moveRemoteBomb itid time pID w
| otherwise = x - 1 | otherwise = x - 1
updatePicture = updatePicture =
set (props . ix pID . prDraw) set (props . ix pID . prDraw)
(\_ -> (,) mempty $ onLayer PtLayer $ uncurryV translate newPos $ remoteBombPic time) (\_ -> (,) mempty $ setDepth 20 $ uncurryV translate newPos $ remoteBombPic time)
+22 -22
View File
@@ -1,35 +1,35 @@
{- | {- |
Uniform management of layers and depths on which pictures are drawn. -} Uniform management of layers and depths on which pictures are drawn. -}
module Dodge.Picture.Layer module Dodge.Picture.Layer
( onLayer ( --onLayer
, onLayerL onLayerL
, levLayer -- , levLayer
, Layer (..) -- , Layer (..)
) where ) where
import Dodge.Picture.Layer.Data import Dodge.Picture.Layer.Data
import Picture import Picture
{- | Uses a layer to set the depth. -} {- | Uses a layer to set the depth. -}
onLayer :: Layer -> Picture -> Picture --onLayer :: Layer -> Picture -> Picture
onLayer l = setDepth $ (1 - fromIntegral (levLayer l) / 100) / 1000 --onLayer l = setDepth $ (1 - fromIntegral (levLayer l) / 100) / 1000
{- | Set a depth according to a list of numbers. {- | Set a depth according to a list of numbers.
Lists are lexicographically ordered if input values are always less than 100. Lists are lexicographically ordered if input values are always less than 100.
Higher numbers will get placed on top of lower numbers. -} Higher numbers will get placed on top of lower numbers. -}
onLayerL :: [Int] -> Picture -> Picture onLayerL :: [Int] -> Picture -> Picture
onLayerL is = setDepth $ (1 - sum (zipWith (/) (map fromIntegral is) $ map (100 **) [1..])) / 1000 onLayerL is = setDepth $ (1 - sum (zipWith (/) (map fromIntegral is) $ map (100 **) [1..])) / 1000
{- | For depth testing, set layer values. -} {- | For depth testing, set layer values. -}
levLayer :: Layer -> Int --levLayer :: Layer -> Int
levLayer BgLayer = 20 --levLayer BgLayer = 20
levLayer PressPlateLayer = 45 --levLayer PressPlateLayer = 45
levLayer CorpseLayer = 50 --levLayer CorpseLayer = 50
levLayer FlItLayer = 55 --levLayer FlItLayer = 55
levLayer CrLayer = 60 --levLayer CrLayer = 60
levLayer WlLayer = 74 --levLayer WlLayer = 74
levLayer GloomLayer = 67 --levLayer GloomLayer = 67
levLayer UPtLayer = 70 --levLayer UPtLayer = 70
levLayer PtLayer = 72 --levLayer PtLayer = 72
levLayer HPtLayer = 73 --levLayer HPtLayer = 73
levLayer ShadowLayer = 75 --levLayer ShadowLayer = 75
levLayer LabelLayer = 80 --levLayer LabelLayer = 80
levLayer InvLayer = 85 --levLayer InvLayer = 85
levLayer MenuDepth = 90 --levLayer MenuDepth = 90
levLayer DebugLayer = 99 --levLayer DebugLayer = 99
+1 -1
View File
@@ -1,7 +1,7 @@
module Dodge.Picture.Layer.Data module Dodge.Picture.Layer.Data
where where
data Layer data Layer''
= PtLayer = PtLayer
| CrLayer | CrLayer
| WlLayer | WlLayer
+1 -2
View File
@@ -5,7 +5,6 @@ module Dodge.Render.Picture
import Dodge.Data import Dodge.Data
--import Dodge.Base.Window --import Dodge.Base.Window
import Dodge.Base.WinScale import Dodge.Base.WinScale
import Dodge.Picture.Layer
import Dodge.Render.HUD import Dodge.Render.HUD
import Dodge.Render.MenuScreen import Dodge.Render.MenuScreen
import Geometry import Geometry
@@ -17,7 +16,7 @@ fixedCoordPictures u = case _menuLayers u of
[ hudDrawings cfig w [ hudDrawings cfig w
, customMouseCursor cfig w , customMouseCursor cfig w
] ]
(lay:_) -> setDepth (-1) . winScale cfig . onLayer MenuDepth $ menuScreen u lay (lay:_) -> setDepth (-1) . winScale cfig $ menuScreen u lay
where where
w = _uvWorld u w = _uvWorld u
cfig = _config u cfig = _config u
+1 -1
View File
@@ -115,7 +115,7 @@ moveInverseShockwave w pt
drawInverseShockwave :: Particle -> Picture drawInverseShockwave :: Particle -> Picture
drawInverseShockwave pt drawInverseShockwave pt
= setLayer 1 $ onLayer PtLayer $ uncurryV translate p = setLayer 1 $ setDepth 20 $ uncurryV translate p
$ color cyan $ thickCircle rad thickness $ color cyan $ thickCircle rad thickness
where where
p = _ptPos pt p = _ptPos pt
+11
View File
@@ -14,6 +14,17 @@ data Verx = Verx
, _vxShadNum :: !ShadNum , _vxShadNum :: !ShadNum
} }
newtype LayNum = LayNum { _unLayNum :: Int } newtype LayNum = LayNum { _unLayNum :: Int }
data Layer
= BottomLayer
| MidLayer
| BloomLayer
| BloomNoZWrite
| TopLayer
| FixedCoordLayer
numLayers :: Int
numLayers = 6
--TODO use synonyms for layer numbers --TODO use synonyms for layer numbers
newtype ShadNum = ShadNum { _unShadNum :: Int } newtype ShadNum = ShadNum { _unShadNum :: Int }
polyNum, polyzNum, bezNum, textNum, arcNum, ellNum :: ShadNum polyNum, polyzNum, bezNum, textNum, arcNum, ellNum :: ShadNum