52 lines
1.6 KiB
Haskell
52 lines
1.6 KiB
Haskell
module Dodge.Debug where
|
|
import Dodge.Data
|
|
import Dodge.Picture
|
|
import Dodge.Picture.Layer
|
|
--import Geometry.Data
|
|
import Picture
|
|
import qualified IntMapHelp as IM
|
|
|
|
import Control.Lens
|
|
|
|
drawCircleAtFor :: Point2 -> Int -> World -> World
|
|
drawCircleAtFor p t w = w & projectiles %~
|
|
IM.insert k Projectile
|
|
{ _pjPos = p
|
|
, _pjStartPos = p
|
|
, _pjVel = (0,0)
|
|
, _pjDraw = \_ -> onLayer PtLayer $ uncurry translate p $ color white $ circleSolid 20
|
|
, _pjID = k
|
|
, _pjUpdate = \_ -> pjTimerF t k
|
|
}
|
|
where
|
|
k = IM.newKey $ _projectiles w
|
|
drawCircleAtForCol :: Point2 -> Int -> Color -> World -> World
|
|
drawCircleAtForCol p t col w = w & projectiles %~
|
|
IM.insert k Projectile
|
|
{ _pjPos = p
|
|
, _pjStartPos = p
|
|
, _pjVel = (0,0)
|
|
, _pjDraw = \_ -> onLayer PtLayer $ uncurry translate p $ color col $ circleSolid 20
|
|
, _pjID = k
|
|
, _pjUpdate = \_ -> pjTimerF t k
|
|
}
|
|
where
|
|
k = IM.newKey $ _projectiles w
|
|
drawLineForCol :: [Point2] -> Int -> Color -> World -> World
|
|
drawLineForCol ps t col w = w & projectiles %~
|
|
IM.insert k Projectile
|
|
{ _pjPos = head ps
|
|
, _pjStartPos = head ps
|
|
, _pjVel = (0,0)
|
|
, _pjDraw = \_ -> onLayer PtLayer $ color col $ lineOfThickness 5 ps
|
|
, _pjID = k
|
|
, _pjUpdate = \_ -> pjTimerF t k
|
|
}
|
|
where
|
|
k = IM.newKey $ _projectiles w
|
|
|
|
pjTimerF :: Int -> Int -> World -> World
|
|
pjTimerF 0 i = projectiles %~ IM.delete i
|
|
pjTimerF time i = projectiles . ix i . pjUpdate .~ (\_ -> pjTimerF (time - 1) i)
|
|
|