Fix bullet particle spawn

This commit is contained in:
2022-04-11 15:00:42 +01:00
parent 3566cec00d
commit 67e6c4a5bd
4 changed files with 27 additions and 27 deletions
+8 -7
View File
@@ -174,28 +174,29 @@ inventoryA = IM.fromList $ zip [0..]
testInventory :: IM.IntMap Item testInventory :: IM.IntMap Item
testInventory = IM.fromList $ zip [0..] testInventory = IM.fromList $ zip [0..]
[ makeTypeCraftNum 9 PIPE [ makeTypeCraftNum 9 PIPE
-- , makeModule INCENDIARYMODULE , makeModule INCENDIARYMODULE
-- , makeModule STATICMODULE , makeModule STATICMODULE
, makeModule CONCUSSMODULE
-- , bounceModule -- , bounceModule
, medkit 50 & itConsumption . itAmount .~ 3 -- , medkit 50 & itConsumption . itAmount .~ 3
, teleportModule , teleportModule
-- , makeTypeCraftNum 1 LIGHTER -- , makeTypeCraftNum 1 LIGHTER
, makeTypeCraftNum 15 TUBE -- , makeTypeCraftNum 15 TUBE
-- , makeTypeCraftNum 9 TRANSFORMER -- , makeTypeCraftNum 9 TRANSFORMER
, makeTypeCraftNum 5 CREATURESENSOR -- , makeTypeCraftNum 5 CREATURESENSOR
-- , makeTypeCraftNum 9 PRISM -- , makeTypeCraftNum 9 PRISM
-- , makeTypeCraftNum 3 DRUM -- , makeTypeCraftNum 3 DRUM
-- , makeTypeCraftNum 3 PUMP -- , makeTypeCraftNum 3 PUMP
-- , makeTypeCraftNum 3 BATTERY -- , makeTypeCraftNum 3 BATTERY
-- , makeTypeCraftNum 1 MAGNET -- , makeTypeCraftNum 1 MAGNET
, makeTypeCraftNum 1 TRANSMITTER -- , makeTypeCraftNum 1 TRANSMITTER
, makeTypeCraftNum 10 HARDWARE , makeTypeCraftNum 10 HARDWARE
, makeTypeCraftNum 3 SPRING , makeTypeCraftNum 3 SPRING
, makeTypeCraftNum 10 CAN , makeTypeCraftNum 10 CAN
-- , makeTypeCraftNum 3 TIN -- , makeTypeCraftNum 3 TIN
, makeTypeCraftNum 3 PLANK , makeTypeCraftNum 3 PLANK
-- , makeTypeCraftNum 1 MOTOR -- , makeTypeCraftNum 1 MOTOR
, makeTypeCraftNum 5 MICROCHIP -- , makeTypeCraftNum 5 MICROCHIP
-- , makeTypeCraftNum 5 AIUNIT -- , makeTypeCraftNum 5 AIUNIT
] ]
stackedInventory :: IM.IntMap Item stackedInventory :: IM.IntMap Item
+10 -11
View File
@@ -71,17 +71,22 @@ targetRBCreature :: Targeting
targetRBCreature = defaultTargeting targetRBCreature = defaultTargeting
& tgUpdate .~ targetRBCreatureUp & tgUpdate .~ targetRBCreatureUp
& tgDraw .~ targetRBCreatureDraw & tgDraw .~ targetRBCreatureDraw
targetCursor :: Targeting targetCursor :: Targeting
targetCursor = defaultTargeting targetCursor = defaultTargeting
& tgUpdate .~ targetUpdateWith targetCursorUpdate & tgUpdate .~ targetUpdateWith targetCursorUpdate
& tgDraw .~ targetSimpleDraw & 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 p <- it ^? itTargeting . tgPos . _Just
return $ winScale cfig return $ winScale cfig
$ setLayer FixedCoordLayer $ setLayer FixedCoordLayer
$ color white $ 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 :: Item -> Creature -> World -> Targeting -> (World, Targeting)
targetRBCreatureUp it cr w t targetRBCreatureUp it cr w t
| not $ _itIsHeld it = (w, t | not $ _itIsHeld it = (w, t
@@ -112,15 +117,9 @@ targetRBCreatureUp it cr w t
Just $ hasLOS cpos (_crPos cr) w Just $ hasLOS cpos (_crPos cr) w
targetRBCreatureDraw :: Int -> Item -> Creature -> Configuration -> World -> Picture targetRBCreatureDraw :: Int -> Item -> Creature -> Configuration -> World -> Picture
targetRBCreatureDraw _ it _ cfig w = fromMaybe mempty $ do targetRBCreatureDraw = targetDraw thepic
p <- it ^? itTargeting . tgPos . _Just
return $ winScale cfig
$ setLayer FixedCoordLayer
$ color white
$ uncurryV translate (worldPosToScreen w p)
thepic
where where
thepic | _tgActive $ _itTargeting it = activeTargetCursorPic thepic it | _tgActive $ _itTargeting it = activeTargetCursorPic
| otherwise = targetCursorPic | otherwise = targetCursorPic
activeTargetCursorPic :: Picture activeTargetCursorPic :: Picture
+1 -1
View File
@@ -1,4 +1,4 @@
module Dodge.Picture.SizeInvariant module Dodge.Picture.SizeInvariant
where where
import Dodge.Data import Dodge.Data
--import Dodge.Base --import Dodge.Base
+8 -8
View File
@@ -115,14 +115,14 @@ moveFlame rotd w pt
+.+ (0.2 *.* vel) +.+ (0.2 *.* vel)
incBall :: RandomGen g => Point2 -> State g Particle incBall :: RandomGen g => Point2 -> State g Particle
incBall vel = do incBall p = do
rot <- state $ randomR (0,3) rot <- state $ randomR (0,3)
return PtZ return PtZ
{ _ptDraw = drawFlameletZ rot { _ptDraw = drawFlameletZ rot
, _ptUpdate = moveFlamelet , _ptUpdate = moveFlamelet
, _ptVel = vel , _ptVel = 0
, _ptColor = red , _ptColor = red
, _ptPos = V2 0 0 , _ptPos = p
, _ptCrIgnore = Nothing , _ptCrIgnore = Nothing
, _ptWidth = 3 , _ptWidth = 3
, _ptTimer = 20 , _ptTimer = 20
@@ -131,11 +131,11 @@ incBall vel = do
} }
concBall :: Point2 -> State g Particle concBall :: Point2 -> State g Particle
concBall _ = return Shockwave concBall p = return Shockwave
{ _ptDraw = drawShockwave { _ptDraw = drawShockwave
, _ptUpdate = mvShockwave [] , _ptUpdate = mvShockwave []
, _ptColor = white , _ptColor = white
, _ptPos = 0 , _ptPos = p
, _ptRad = 15 , _ptRad = 15
, _ptDam = 4 , _ptDam = 4
, _ptPush = 1 , _ptPush = 1
@@ -145,12 +145,12 @@ concBall _ = return Shockwave
aStaticBall :: Point2 -> State g Particle aStaticBall :: Point2 -> State g Particle
aStaticBall vel = return PtZ aStaticBall p = return PtZ
{ _ptDraw = drawStaticBall { _ptDraw = drawStaticBall
, _ptUpdate = moveStaticBall , _ptUpdate = moveStaticBall
, _ptVel = vel , _ptVel = 0
, _ptColor = blue , _ptColor = blue
, _ptPos = 0 , _ptPos = p
, _ptCrIgnore = Nothing , _ptCrIgnore = Nothing
, _ptWidth = 3 , _ptWidth = 3
, _ptTimer = 20 , _ptTimer = 20