51 lines
1.7 KiB
Haskell
51 lines
1.7 KiB
Haskell
module Dodge.Debug where
|
|
|
|
import Dodge.Data
|
|
import Dodge.Base
|
|
|
|
import Geometry.Data
|
|
import Picture
|
|
|
|
import Control.Lens
|
|
|
|
|
|
import qualified Data.IntMap.Strict as IM
|
|
|
|
drawCircleAtFor :: Point2 -> Int -> World -> World
|
|
drawCircleAtFor p t w =
|
|
let n = newParticleKey w
|
|
in over particles ( IM.insert n
|
|
Particle { _ptPos = p
|
|
, _ptStartPos = p
|
|
, _ptVel = (0,0)
|
|
, _ptPict = onLayer PtLayer $ uncurry translate p $ color white $ circleSolid 20
|
|
, _ptID = n
|
|
, _ptUpdate = ptTimer t n
|
|
} ) w
|
|
drawCircleAtForCol :: Point2 -> Int -> Color -> World -> World
|
|
drawCircleAtForCol p t col w =
|
|
let n = newParticleKey w
|
|
in over particles ( IM.insert n
|
|
Particle { _ptPos = p
|
|
, _ptStartPos = p
|
|
, _ptVel = (0,0)
|
|
, _ptPict = onLayer PtLayer $ uncurry translate p $ color col $ circleSolid 20
|
|
, _ptID = n
|
|
, _ptUpdate = ptTimer t n
|
|
} ) w
|
|
drawLineForCol :: [Point2] -> Int -> Color -> World -> World
|
|
drawLineForCol ps t col w =
|
|
let n = newParticleKey w
|
|
in over particles ( IM.insert n
|
|
Particle { _ptPos = head ps
|
|
, _ptStartPos = head ps
|
|
, _ptVel = (0,0)
|
|
, _ptPict = onLayer PtLayer $ color col $ lineOfThickness 5 ps
|
|
, _ptID = n
|
|
, _ptUpdate = ptTimer t n
|
|
} ) w
|
|
|
|
ptTimer :: Int -> Int -> World -> World
|
|
ptTimer 0 i = over particles (IM.delete i)
|
|
ptTimer time i = set (particles . ix i . ptUpdate) $ ptTimer (time - 1) i
|