From 67e6c4a5bd9f986826a6b9f190b2b7bf591c85bd Mon Sep 17 00:00:00 2001 From: justin Date: Mon, 11 Apr 2022 15:00:42 +0100 Subject: [PATCH] Fix bullet particle spawn --- src/Dodge/Creature.hs | 15 ++++++++------- src/Dodge/Item/Weapon/ExtraEffect.hs | 21 ++++++++++----------- src/Dodge/Picture/SizeInvariant.hs | 2 +- src/Dodge/WorldEvent/SpawnParticle.hs | 16 ++++++++-------- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/Dodge/Creature.hs b/src/Dodge/Creature.hs index 9349d8972..d42b4583a 100644 --- a/src/Dodge/Creature.hs +++ b/src/Dodge/Creature.hs @@ -174,28 +174,29 @@ inventoryA = IM.fromList $ zip [0..] testInventory :: IM.IntMap Item testInventory = IM.fromList $ zip [0..] [ makeTypeCraftNum 9 PIPE --- , makeModule INCENDIARYMODULE --- , makeModule STATICMODULE + , makeModule INCENDIARYMODULE + , makeModule STATICMODULE + , makeModule CONCUSSMODULE -- , bounceModule - , medkit 50 & itConsumption . itAmount .~ 3 +-- , medkit 50 & itConsumption . itAmount .~ 3 , teleportModule -- , makeTypeCraftNum 1 LIGHTER - , makeTypeCraftNum 15 TUBE +-- , makeTypeCraftNum 15 TUBE -- , makeTypeCraftNum 9 TRANSFORMER - , makeTypeCraftNum 5 CREATURESENSOR +-- , makeTypeCraftNum 5 CREATURESENSOR -- , makeTypeCraftNum 9 PRISM -- , makeTypeCraftNum 3 DRUM -- , makeTypeCraftNum 3 PUMP -- , makeTypeCraftNum 3 BATTERY -- , makeTypeCraftNum 1 MAGNET - , makeTypeCraftNum 1 TRANSMITTER +-- , makeTypeCraftNum 1 TRANSMITTER , makeTypeCraftNum 10 HARDWARE , makeTypeCraftNum 3 SPRING , makeTypeCraftNum 10 CAN -- , makeTypeCraftNum 3 TIN , makeTypeCraftNum 3 PLANK -- , makeTypeCraftNum 1 MOTOR - , makeTypeCraftNum 5 MICROCHIP +-- , makeTypeCraftNum 5 MICROCHIP -- , makeTypeCraftNum 5 AIUNIT ] stackedInventory :: IM.IntMap Item diff --git a/src/Dodge/Item/Weapon/ExtraEffect.hs b/src/Dodge/Item/Weapon/ExtraEffect.hs index a07092fdd..3015c9e39 100644 --- a/src/Dodge/Item/Weapon/ExtraEffect.hs +++ b/src/Dodge/Item/Weapon/ExtraEffect.hs @@ -71,17 +71,22 @@ targetRBCreature :: Targeting targetRBCreature = defaultTargeting & tgUpdate .~ targetRBCreatureUp & tgDraw .~ targetRBCreatureDraw + targetCursor :: Targeting targetCursor = defaultTargeting & tgUpdate .~ targetUpdateWith targetCursorUpdate & tgDraw .~ targetSimpleDraw -targetSimpleDraw :: Int -> Item -> Creature -> Configuration -> World -> Picture -targetSimpleDraw _ it _ cfig w = fromMaybe mempty $ do + +targetDraw :: (Item -> Picture) -> Int -> Item -> Creature -> Configuration -> World -> Picture +targetDraw f _ it _ cfig w = fromMaybe mempty $ do p <- it ^? itTargeting . tgPos . _Just return $ winScale cfig $ setLayer FixedCoordLayer $ color white - $ uncurryV translate (worldPosToScreen w p) activeTargetCursorPic + $ uncurryV translate (worldPosToScreen w p) + $ f it +targetSimpleDraw :: Int -> Item -> Creature -> Configuration -> World -> Picture +targetSimpleDraw = targetDraw $ const activeTargetCursorPic targetRBCreatureUp :: Item -> Creature -> World -> Targeting -> (World, Targeting) targetRBCreatureUp it cr w t | not $ _itIsHeld it = (w, t @@ -112,15 +117,9 @@ targetRBCreatureUp it cr w t Just $ hasLOS cpos (_crPos cr) w targetRBCreatureDraw :: Int -> Item -> Creature -> Configuration -> World -> Picture -targetRBCreatureDraw _ it _ cfig w = fromMaybe mempty $ do - p <- it ^? itTargeting . tgPos . _Just - return $ winScale cfig - $ setLayer FixedCoordLayer - $ color white - $ uncurryV translate (worldPosToScreen w p) - thepic +targetRBCreatureDraw = targetDraw thepic where - thepic | _tgActive $ _itTargeting it = activeTargetCursorPic + thepic it | _tgActive $ _itTargeting it = activeTargetCursorPic | otherwise = targetCursorPic activeTargetCursorPic :: Picture diff --git a/src/Dodge/Picture/SizeInvariant.hs b/src/Dodge/Picture/SizeInvariant.hs index 3c672f68c..864f2dc6c 100644 --- a/src/Dodge/Picture/SizeInvariant.hs +++ b/src/Dodge/Picture/SizeInvariant.hs @@ -1,4 +1,4 @@ -module Dodge.Picture.SizeInvariant +module Dodge.Picture.SizeInvariant where import Dodge.Data --import Dodge.Base diff --git a/src/Dodge/WorldEvent/SpawnParticle.hs b/src/Dodge/WorldEvent/SpawnParticle.hs index 5794c281a..f16db0646 100644 --- a/src/Dodge/WorldEvent/SpawnParticle.hs +++ b/src/Dodge/WorldEvent/SpawnParticle.hs @@ -115,14 +115,14 @@ moveFlame rotd w pt +.+ (0.2 *.* vel) incBall :: RandomGen g => Point2 -> State g Particle -incBall vel = do +incBall p = do rot <- state $ randomR (0,3) return PtZ { _ptDraw = drawFlameletZ rot , _ptUpdate = moveFlamelet - , _ptVel = vel + , _ptVel = 0 , _ptColor = red - , _ptPos = V2 0 0 + , _ptPos = p , _ptCrIgnore = Nothing , _ptWidth = 3 , _ptTimer = 20 @@ -131,11 +131,11 @@ incBall vel = do } concBall :: Point2 -> State g Particle -concBall _ = return Shockwave +concBall p = return Shockwave { _ptDraw = drawShockwave , _ptUpdate = mvShockwave [] , _ptColor = white - , _ptPos = 0 + , _ptPos = p , _ptRad = 15 , _ptDam = 4 , _ptPush = 1 @@ -145,12 +145,12 @@ concBall _ = return Shockwave aStaticBall :: Point2 -> State g Particle -aStaticBall vel = return PtZ +aStaticBall p = return PtZ { _ptDraw = drawStaticBall , _ptUpdate = moveStaticBall - , _ptVel = vel + , _ptVel = 0 , _ptColor = blue - , _ptPos = 0 + , _ptPos = p , _ptCrIgnore = Nothing , _ptWidth = 3 , _ptTimer = 20