Randomize spark movement
This commit is contained in:
@@ -43,11 +43,7 @@ import Shape
|
||||
import ShapePicture
|
||||
|
||||
-- this can almost certainly be made more efficient
|
||||
foldCr ::
|
||||
[Creature -> World -> World] ->
|
||||
Creature ->
|
||||
World ->
|
||||
World
|
||||
foldCr :: [Creature -> World -> World] -> Creature -> World -> World
|
||||
foldCr xs cr w = foldl' f w xs
|
||||
where
|
||||
f w' g = case w' ^? cWorld . lWorld . creatures . ix (_crID cr) of
|
||||
@@ -256,7 +252,6 @@ trySynthBullet loc w = fromMaybe w $ do
|
||||
where
|
||||
itm = loc ^. locLDT . ldtValue . _1
|
||||
|
||||
|
||||
updateHeldRootItem :: Creature -> World -> World
|
||||
updateHeldRootItem cr = fromMaybe id $ do
|
||||
invid <- cr ^? crManipulation . manObject . imRootSelectedItem
|
||||
|
||||
@@ -50,7 +50,6 @@ collectDamageTypes :: [Damage] -> M.Map DamageType Int
|
||||
collectDamageTypes = foldl' (flip f) M.empty
|
||||
where
|
||||
f dm = at (dmType dm) . non 0 +~ _dmAmount dm
|
||||
--f dm = M.insertWith (+) (dmType dm) (_dmAmount dm)
|
||||
|
||||
maxDamageType :: [Damage] -> Maybe (DamageType, Int)
|
||||
maxDamageType = safeMinimumOn (negate . snd) . M.assocs . collectDamageTypes
|
||||
|
||||
@@ -33,6 +33,3 @@ data Damage
|
||||
|
||||
makeLenses ''Damage
|
||||
deriveJSON defaultOptions ''Damage
|
||||
--deriveJSON defaultOptions ''DamageType
|
||||
--instance ToJSONKey DamageType
|
||||
--instance FromJSONKey DamageType
|
||||
|
||||
+6
-2
@@ -18,17 +18,21 @@ updateSpark :: World -> Spark -> (World, Maybe Spark)
|
||||
updateSpark w sk
|
||||
| magV (_skVel sk) < 1 = (w, Nothing)
|
||||
| otherwise = case thingHit sp ep w of
|
||||
Nothing -> (w, Just $ sk & skPos .~ ep & skVel *~ 0.9 & skOldPos .~ sp)
|
||||
Nothing -> (w & randGen .~ g, Just $ sk & skPos .~ ep & skVel *~ 0.9
|
||||
& skVel %~ rotateV a
|
||||
& skOldPos .~ sp)
|
||||
Just (hp, hthing) ->
|
||||
( sparkDam sk hthing w
|
||||
, Just $ sk & skPos .~ hp & skOldPos .~ sp & skVel .~ 0
|
||||
)
|
||||
where
|
||||
(a,g) = randomR (-x,x) (_randGen w)
|
||||
x = 1
|
||||
sp = _skPos sk
|
||||
ep = sp + _skVel sk
|
||||
|
||||
sparkDam :: Spark -> Either Creature Wall -> World -> World
|
||||
sparkDam sk = damageCrWl (sparkToDamage sk)
|
||||
sparkDam = damageCrWl . sparkToDamage
|
||||
|
||||
sparkToDamage :: Spark -> Damage
|
||||
sparkToDamage sp = case _skType sp of
|
||||
|
||||
Reference in New Issue
Block a user