Almost working shadows

This commit is contained in:
2021-06-30 00:35:41 +02:00
parent 3056e6384b
commit 357206f060
6 changed files with 46 additions and 20 deletions
+7 -4
View File
@@ -1,3 +1,4 @@
{-# LANGUAGE TupleSections #-}
{-
Inanimate objects such as lamps, barrels, etc
-}
@@ -17,6 +18,8 @@ import Dodge.Creature.Update hiding (CRUpdate)
import Picture
import qualified IntMapHelp as IM
import Geometry
import Geometry.Vector3D
import Polyhedra
import Control.Lens
@@ -33,15 +36,15 @@ lamp = defaultInanimate
}
lampPic :: Picture
lampPic = pictures
[ setDepth (0.049) $ color white $ polygon $ rectNSEW 5 (-5) 5 (-5)
, setDepth (0) $ color white $ circleSolid 3
[ pictures . map (Poly3D 0 . map ((, blue) . (-.-.- (2.5,2.5,0)))) $ boxXYZ 5 5 99
, setDepth (100) $ color white $ circleSolid 3
]
initialiseLamp :: CRUpdate
initialiseLamp w (f,g) cr = ( (addLS . f , g), Just $ cr & crUpdate .~ updateLamp i)
where
i = IM.newKey $ _lightSources $ f w -- to give different lights different keys
addLS = over lightSources (IM.insert i (lightAt (x,y,100) i))
addLS = over lightSources (IM.insert i (lightAt (x,y,20) i))
(x,y) = _crPos cr
updateLamp :: Int -> CRUpdate
@@ -53,7 +56,7 @@ updateLamp i = unrandUpdate handleLS internalUpdate
| otherwise = w & lightSources . ix i . lsPos .~ f cPos
where
cPos = _crPos cr
f (x,y) = (x,y,100)
f (x,y) = (x,y,120)
internalUpdate cr
| _crHP cr < 0 = Nothing
| otherwise = Just $ doDamage cr