Add trajectory to grenades, various refactoring
This commit is contained in:
@@ -113,19 +113,19 @@ aTractorBeam
|
||||
aTractorBeam col cr w
|
||||
= set (creatures . ix cid . crInv . ix itRef . itUse)
|
||||
(\_ -> aTractorBeam ((col + 1) `mod` 10))
|
||||
$ over projectiles (IM.insert i (tractorBeamAt col i pos dir)) w
|
||||
$ over props (IM.insert i (tractorBeamAt col i pos dir)) w
|
||||
where
|
||||
i = newProjectileKey w
|
||||
cid = _crID cr
|
||||
pos = _crPos cr +.+ ((_crRad cr + 10) *.* unitVectorAtAngle dir)
|
||||
dir = _crDir cr
|
||||
itRef = _crInvSel cr
|
||||
tractorBeamAt :: Int -> Int -> Point2 -> Float -> Projectile
|
||||
tractorBeamAt :: Int -> Int -> Point2 -> Float -> Prop
|
||||
tractorBeamAt colID i pos dir = Projectile
|
||||
{ _pjPos = pos
|
||||
, _pjStartPos = p'
|
||||
, _pjVel = d
|
||||
, _pjDraw = const blank
|
||||
, _prDraw = const (mempty,blank)
|
||||
, _pjID = i
|
||||
, _pjUpdate = \_ -> updateTractor colID 10 i
|
||||
}
|
||||
@@ -137,12 +137,12 @@ tractorBeamAt colID i pos dir = Projectile
|
||||
The interaction of this with objects, walls etc needs more thought. -}
|
||||
updateTractor :: Int -> Int -> Int -> World -> World
|
||||
updateTractor colID time i w
|
||||
| time > 0 = set (projectiles . ix i . pjUpdate) (\_ -> updateTractor colID (time-1) i)
|
||||
$ set (projectiles . ix i . pjDraw) (const pic)
|
||||
| time > 0 = set (props . ix i . pjUpdate) (\_ -> updateTractor colID (time-1) i)
|
||||
$ set (props . ix i . prDraw) (const (mempty,mempty))
|
||||
$ over creatures (IM.map tractCr)
|
||||
$ over floorItems (IM.map tractFlIt)
|
||||
w
|
||||
| otherwise = over projectiles (IM.delete i) w
|
||||
| otherwise = over props (IM.delete i) w
|
||||
where
|
||||
tractCr cr
|
||||
| circOnSeg p1 p2 cP 10
|
||||
@@ -166,7 +166,7 @@ updateTractor colID time i w
|
||||
iP = _flItPos it
|
||||
m | dist iP p1 < 350 = 1
|
||||
| otherwise = (410 - dist iP p1) / 60
|
||||
pj = _projectiles w IM.! i
|
||||
pj = _props w IM.! i
|
||||
q = _pjVel pj
|
||||
p1 = _pjPos pj
|
||||
p' = _pjStartPos pj
|
||||
|
||||
Reference in New Issue
Block a user