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