Refactor light sources

This commit is contained in:
2021-11-28 16:53:26 +00:00
parent 1d9dd3e4e0
commit 618653a86e
28 changed files with 169 additions and 155 deletions
+2 -2
View File
@@ -87,7 +87,7 @@ initialiseColorLamp col h cr _ = ( Endo addLS , Just $ cr & crUpdate .~ updateLa
where
i = _crID cr
addLS w = w
& lightSources %~ IM.insert lsid (colorLightAt col (V3 x y h) lsid)
& lightSources %~ IM.insert lsid (lsColPosID col (V3 x y h) lsid)
& creatures . ix i . crUpdate .~ updateLamp h lsid
where
lsid = IM.newKey $ _lightSources w
@@ -99,7 +99,7 @@ updateLamp h i = unrandUpdate handleLS internalUpdate
handleLS cr w
| _crHP cr < 0 = explosionFlashAt cPos
$ mkSoundBreakGlass cPos w & lightSources %~ IM.delete i
| otherwise = w & lightSources . ix i . lsPos .~ f cPos
| otherwise = w & lightSources . ix i . lsParam . lsPos .~ f cPos
where
cPos = _crPos cr
f (V2 x y) = V3 x y h
+9 -9
View File
@@ -4,7 +4,7 @@ module Dodge.Creature.YourControl
import Dodge.Data
import Dodge.Creature.Impulse.Movement
import Dodge.Update.UsingInput
import Dodge.Config.KeyConfig
--import Dodge.Config.KeyConfig
import Geometry
import Control.Lens
@@ -49,16 +49,16 @@ wasdWithAiming w speed i cr
*.* rotateV (_cameraRot w) (_mousePos w)
_ -> normalizeAngle $ argV (_mousePos w) + _cameraRot w
wasdM :: World -> SDL.Scancode -> Point2
wasdM w scancode
| scancode == moveUpKey (_keyConfig w) = V2 0 1
| scancode == moveDownKey (_keyConfig w) = V2 0 (-1)
| scancode == moveRightKey (_keyConfig w) = V2 1 0
| scancode == moveLeftKey (_keyConfig w) = V2 (-1) 0
wasdM _ _ = V2 0 0
wasdM :: SDL.Scancode -> Point2
wasdM scancode = case scancode of
SDL.ScancodeW -> V2 0 1
SDL.ScancodeS -> V2 0 (-1)
SDL.ScancodeD -> V2 1 0
SDL.ScancodeA -> V2 (-1) 0
_ -> V2 0 0
wasdDir :: World -> Point2
wasdDir w = foldr ((+.+) . wasdM w) (V2 0 0) $ _keys w
wasdDir w = foldr ((+.+) . wasdM) (V2 0 0) $ _keys w
{- | Set posture according to mouse presses. -}
mouseActionsCr :: S.Set SDL.MouseButton -> Creature -> Creature