Add ItEffect data as parameter to the effect itself

This commit is contained in:
jgk
2021-05-24 21:37:42 +02:00
parent 38682049c4
commit a7d4d8911d
12 changed files with 109 additions and 59 deletions
+6 -6
View File
@@ -16,7 +16,7 @@ drawCircleAtFor p t w = w & projectiles %~
, _pjVel = (0,0)
, _pjDraw = \_ -> onLayer PtLayer $ uncurry translate p $ color white $ circleSolid 20
, _pjID = k
, _pjUpdate = pjTimer t k
, _pjUpdate = \_ -> pjTimerF t k
}
where
k = IM.newKey $ _projectiles w
@@ -28,7 +28,7 @@ drawCircleAtForCol p t col w = w & projectiles %~
, _pjVel = (0,0)
, _pjDraw = \_ -> onLayer PtLayer $ uncurry translate p $ color col $ circleSolid 20
, _pjID = k
, _pjUpdate = pjTimer t k
, _pjUpdate = \_ -> pjTimerF t k
}
where
k = IM.newKey $ _projectiles w
@@ -40,12 +40,12 @@ drawLineForCol ps t col w = w & projectiles %~
, _pjVel = (0,0)
, _pjDraw = \_ -> onLayer PtLayer $ color col $ lineOfThickness 5 ps
, _pjID = k
, _pjUpdate = pjTimer t k
, _pjUpdate = \_ -> pjTimerF t k
}
where
k = IM.newKey $ _projectiles w
pjTimer :: Int -> Int -> World -> World
pjTimer 0 i = projectiles %~ IM.delete i
pjTimer time i = projectiles . ix i . pjUpdate .~ pjTimer (time - 1) i
pjTimerF :: Int -> Int -> World -> World
pjTimerF 0 i = projectiles %~ IM.delete i
pjTimerF time i = projectiles . ix i . pjUpdate .~ (\_ -> pjTimerF (time - 1) i)