Runtime broken level generation

This commit is contained in:
jgk
2021-03-29 11:27:30 +02:00
parent e0570ed54c
commit c959b7d59c
9 changed files with 356 additions and 369 deletions
+36 -33
View File
@@ -12,39 +12,42 @@ import Control.Lens
import qualified Data.IntMap.Strict as IM
drawCircleAtFor :: Point2 -> Int -> World -> World
drawCircleAtFor p t w =
let n = newProjectileKey w
in over projectiles ( IM.insert n
Projectile { _ptPos = p
, _ptStartPos = p
, _ptVel = (0,0)
, _ptPict = onLayer PtLayer $ uncurry translate p $ color white $ circleSolid 20
, _ptID = n
, _ptUpdate = ptTimer t n
} ) w
drawCircleAtFor p t w = w & projectiles %~
IM.insert k Projectile
{ _pjPos = p
, _pjStartPos = p
, _pjVel = (0,0)
, _pjPict = onLayer PtLayer $ uncurry translate p $ color white $ circleSolid 20
, _pjID = k
, _pjUpdate = pjTimer t k
}
where
k = newKey $ _projectiles w
drawCircleAtForCol :: Point2 -> Int -> Color -> World -> World
drawCircleAtForCol p t col w =
let n = newProjectileKey w
in over projectiles ( IM.insert n
Projectile { _ptPos = p
, _ptStartPos = p
, _ptVel = (0,0)
, _ptPict = onLayer PtLayer $ uncurry translate p $ color col $ circleSolid 20
, _ptID = n
, _ptUpdate = ptTimer t n
} ) w
drawCircleAtForCol p t col w = w & projectiles %~
IM.insert k Projectile
{ _pjPos = p
, _pjStartPos = p
, _pjVel = (0,0)
, _pjPict = onLayer PtLayer $ uncurry translate p $ color col $ circleSolid 20
, _pjID = k
, _pjUpdate = pjTimer t k
}
where
k = newKey $ _projectiles w
drawLineForCol :: [Point2] -> Int -> Color -> World -> World
drawLineForCol ps t col w =
let n = newProjectileKey w
in over projectiles ( IM.insert n
Projectile { _ptPos = head ps
, _ptStartPos = head ps
, _ptVel = (0,0)
, _ptPict = onLayer PtLayer $ color col $ lineOfThickness 5 ps
, _ptID = n
, _ptUpdate = ptTimer t n
} ) w
drawLineForCol ps t col w = w & projectiles %~
IM.insert k Projectile
{ _pjPos = head ps
, _pjStartPos = head ps
, _pjVel = (0,0)
, _pjPict = onLayer PtLayer $ color col $ lineOfThickness 5 ps
, _pjID = k
, _pjUpdate = pjTimer t k
}
where
k = newKey $ _projectiles w
ptTimer :: Int -> Int -> World -> World
ptTimer 0 i = over projectiles (IM.delete i)
ptTimer time i = set (projectiles . ix i . ptUpdate) $ ptTimer (time - 1) i
pjTimer :: Int -> Int -> World -> World
pjTimer 0 i = projectiles %~ IM.delete i
pjTimer time i = projectiles . ix i . pjUpdate .~ pjTimer (time - 1) i