Stop bullets when they hit walls
This commit is contained in:
@@ -51,9 +51,18 @@ mvPt pt = Just $ pt
|
||||
|
||||
destroyAt :: Point2 -> Particle -> Maybe Particle
|
||||
destroyAt hitp pt = Just $ pt
|
||||
& ptUpdate .~ killBulletUpdate
|
||||
& btTrail' %~ (hitp :)
|
||||
& btTimer' %~ (\t -> min 3 (t-1))
|
||||
|
||||
killBulletUpdate :: World -> Particle -> (World,Maybe Particle)
|
||||
killBulletUpdate w pt
|
||||
| _btTimer' pt <= 0 = (w,Nothing)
|
||||
| otherwise = (w
|
||||
,Just $ pt & btTimer' -~ 1
|
||||
& btTrail' %~ (\(x:xs) -> (x:x:xs))
|
||||
)
|
||||
|
||||
penWalls
|
||||
:: HitCreatureEffect
|
||||
-> HitWallEffect
|
||||
|
||||
@@ -31,12 +31,13 @@ thingsHit sp ep w
|
||||
where
|
||||
hitCrs = IM.elems
|
||||
$ IM.filter (\cr -> circOnSeg sp ep (_crPos cr) (_crRad cr))
|
||||
$ _creatures w
|
||||
-- $ creaturesAlongLine sp ep w
|
||||
crPs = map (\cr -> ssaTriPoint ep (_crPos cr) sp (_crRad cr)) hitCrs
|
||||
-- $ _creatures w
|
||||
$ creaturesAlongLine sp ep w
|
||||
crPs = map (\cr -> ssaTriPoint ep (_crPos cr) sp (_crRad cr)) hitCrs
|
||||
crs = zip crPs (map Left hitCrs)
|
||||
hitWls = wallsOnLine sp ep (IM.unions [f b $ f a $ _znObjects $ _wallsZone w | a<-[x-1,x,x+1]
|
||||
, b<-[y-1,y,y+1]])
|
||||
--hitWls = wallsOnLine sp ep $ _walls w
|
||||
(x,y) = zoneOfPoint (0.5 *.* (sp +.+ ep))
|
||||
f i m = case IM.lookup i m of
|
||||
Just val -> val
|
||||
|
||||
Reference in New Issue
Block a user