Add trajectory to grenades, various refactoring
This commit is contained in:
+11
-11
@@ -14,45 +14,45 @@ import qualified Data.IntSet as IS
|
||||
import Control.Lens
|
||||
|
||||
drawCircleAtFor :: Point2 -> Int -> World -> World
|
||||
drawCircleAtFor p t w = w & projectiles %~
|
||||
drawCircleAtFor p t w = w & props %~
|
||||
IM.insert k Projectile
|
||||
{ _pjPos = p
|
||||
, _pjStartPos = p
|
||||
, _pjVel = V2 0 0
|
||||
, _pjDraw = \_ -> onLayer PtLayer $ uncurryV translate p $ color white $ circleSolid 20
|
||||
, _prDraw = \_ -> (,) mempty $ onLayer PtLayer $ uncurryV translate p $ color white $ circleSolid 20
|
||||
, _pjID = k
|
||||
, _pjUpdate = \_ -> pjTimerF t k
|
||||
}
|
||||
where
|
||||
k = IM.newKey $ _projectiles w
|
||||
k = IM.newKey $ _props w
|
||||
drawCircleAtForCol :: Point2 -> Int -> Color -> World -> World
|
||||
drawCircleAtForCol p t col w = w & projectiles %~
|
||||
drawCircleAtForCol p t col w = w & props %~
|
||||
IM.insert k Projectile
|
||||
{ _pjPos = p
|
||||
, _pjStartPos = p
|
||||
, _pjVel = V2 0 0
|
||||
, _pjDraw = \_ -> onLayer PtLayer $ uncurryV translate p $ color col $ circleSolid 20
|
||||
, _prDraw = \_ -> (,) mempty $ onLayer PtLayer $ uncurryV translate p $ color col $ circleSolid 20
|
||||
, _pjID = k
|
||||
, _pjUpdate = \_ -> pjTimerF t k
|
||||
}
|
||||
where
|
||||
k = IM.newKey $ _projectiles w
|
||||
k = IM.newKey $ _props w
|
||||
drawLineForCol :: [Point2] -> Int -> Color -> World -> World
|
||||
drawLineForCol ps t col w = w & projectiles %~
|
||||
drawLineForCol ps t col w = w & props %~
|
||||
IM.insert k Projectile
|
||||
{ _pjPos = head ps
|
||||
, _pjStartPos = head ps
|
||||
, _pjVel = V2 0 0
|
||||
, _pjDraw = \_ -> onLayer PtLayer $ color col $ lineOfThickness 5 ps
|
||||
, _prDraw = \_ -> (,) mempty $ onLayer PtLayer $ color col $ lineOfThickness 5 ps
|
||||
, _pjID = k
|
||||
, _pjUpdate = \_ -> pjTimerF t k
|
||||
}
|
||||
where
|
||||
k = IM.newKey $ _projectiles w
|
||||
k = IM.newKey $ _props w
|
||||
|
||||
pjTimerF :: Int -> Int -> World -> World
|
||||
pjTimerF 0 i = projectiles %~ IM.delete i
|
||||
pjTimerF time i = projectiles . ix i . pjUpdate .~ (\_ -> pjTimerF (time - 1) i)
|
||||
pjTimerF 0 i = props %~ IM.delete i
|
||||
pjTimerF time i = props . ix i . pjUpdate .~ (\_ -> pjTimerF (time - 1) i)
|
||||
|
||||
drawDDA :: IM.IntMap IS.IntSet -> Picture
|
||||
drawDDA = setLayer 1 . color (withAlpha 0.5 green) . IM.foldlWithKey' f blank
|
||||
|
||||
Reference in New Issue
Block a user