From 1c9923bb91d9a24eb35024ad6f4f243758c4535f Mon Sep 17 00:00:00 2001 From: justin Date: Thu, 12 Jan 2023 16:09:19 +0000 Subject: [PATCH] Continue work on bullet drawing --- src/Dodge/Bullet.hs | 2 +- src/Dodge/Item/Draw/SPic.hs | 38 ++++++++++++++++++++++++++++++++----- src/Dodge/Item/Info.hs | 6 +++--- src/Dodge/Render/HUD.hs | 2 +- 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/src/Dodge/Bullet.hs b/src/Dodge/Bullet.hs index a65694f80..830a6b80d 100644 --- a/src/Dodge/Bullet.hs +++ b/src/Dodge/Bullet.hs @@ -106,7 +106,7 @@ makeFragBullets p w = w & cWorld . lWorld . instantBullets .++~ bus bus = zipWith f (take 10 as) (take 10 ss) as = randomRs (0, 2 * pi) $ _randGen w ss = randomRs (5, 15) $ _randGen w - f a s = defaultBullet & buVel .~ s *.* (unitVectorAtAngle a) + f a s = defaultBullet & buVel .~ s *.* unitVectorAtAngle a & buDrag .~ 0.8 & buPos .~ p & buOldPos .~ p diff --git a/src/Dodge/Item/Draw/SPic.hs b/src/Dodge/Item/Draw/SPic.hs index e21f5d21a..5c33b7842 100644 --- a/src/Dodge/Item/Draw/SPic.hs +++ b/src/Dodge/Item/Draw/SPic.hs @@ -240,20 +240,48 @@ makeSingleClipAt p it = case it ^? itUse . heldConsumption . laLoaded of makeTinClipAt :: Float -> Point3 -> Item -> Shape makeTinClipAt r p it = translateSH p . overPosSH (rotate3z r) $ - (upperPrismPoly 1 $ + colorSH midcol (upperPrismPoly 1 ( reverse $ - rectNSWE 0 (- y) (-2) 2) <> tips + rectNSWE 0 (- y) (-2) 2)) <> tips <> tails where + midcol = maybe black bulletEffectColor + (it ^? itUse . heldConsumption . laAmmoType . amBullet . buEffect) y = fromIntegral y' * 0.3 y' = fromMaybe 0 $ it ^? itUse . heldConsumption . laLoaded tips = fromMaybe mempty $ do - ebt <- it ^? itUse . heldConsumption . laAmmoType . amBullet . buSpawn . spawnEBT + ebt <- it ^? itUse . heldConsumption . laAmmoType . amBullet . buSpawn return $ colorSH (bulletPayloadColor ebt) $ upperPrismPoly 1.1 $ reverse $ rectNSWE 0 (- y) (-2) (-1) + tails = fromMaybe mempty $ do + ebt <- it ^? itUse . heldConsumption . laAmmoType . amBullet . buTrajectory + return $ colorSH (bulletTrajColor ebt) $ upperPrismPoly 1.1 $ + reverse $ + rectNSWE 0 (- y) 1 2 -bulletPayloadColor :: EnergyBallType -> Color -bulletPayloadColor ebt = case ebt of +bulletEffectColor :: BulletEffect -> Color +bulletEffectColor x = case x of + DestroyBullet -> black + BounceBullet -> mixColors 0.5 0.5 black yellow + PenetrateBullet -> mixColors 0.5 0.5 black blue + +bulletTrajColor :: BulletTrajectory -> Color +bulletTrajColor x = case x of + BasicBulletTrajectory -> black + BezierTrajectory {} -> chartreuse + FlechetteTrajectory {} -> white + MagnetTrajectory {} -> yellow + +bulletPayloadColor :: BulletSpawn -> Color +bulletPayloadColor x = case x of + BulBall y -> energyBallColor y + BulSpark -> black + BulFlak -> chartreuse + BulFrag -> magenta + BulGas -> green + +energyBallColor :: EnergyBallType -> Color +energyBallColor ebt = case ebt of IncBall -> orange TeslaBall -> cyan ConcBall -> white diff --git a/src/Dodge/Item/Info.hs b/src/Dodge/Item/Info.hs index 545562b35..97512fffb 100644 --- a/src/Dodge/Item/Info.hs +++ b/src/Dodge/Item/Info.hs @@ -13,7 +13,7 @@ itemInfo itm = itmBaseInfo itm ++ " " ++ itmUsageInfo itm ++ itmModuleInfo (itm ^. itType . iyModules) itmSpaceInfo :: Item -> String -itmSpaceInfo itm = case (ceiling $ _itInvSize itm) of +itmSpaceInfo itm = case ceiling $ _itInvSize itm of 1 -> " It takes up one inventory slot. " x -> " It takes up " ++ showInt x ++ " inventory slots. " @@ -251,8 +251,8 @@ itmModuleInfo m makeCommaList :: [String] -> String makeCommaList [] = "" -makeCommaList (x:[]) = x ++ "." -makeCommaList (x:y:[]) = x ++ " and " ++ y ++ "." +makeCommaList [x] = x ++ "." +makeCommaList [x,y] = x ++ " and " ++ y ++ "." makeCommaList (x:xs) = x ++ ", " ++ makeCommaList xs moduleInfo :: ModuleSlot -> String diff --git a/src/Dodge/Render/HUD.hs b/src/Dodge/Render/HUD.hs index 513fe2ef6..cb52dce8b 100644 --- a/src/Dodge/Render/HUD.hs +++ b/src/Dodge/Render/HUD.hs @@ -126,7 +126,7 @@ drawExamineInventory cfig mtweaki w = closeObjectInfo :: Int -> Either FloorItem Button -> String closeObjectInfo n x = case x of - Left (FlIt {_flIt = itm}) -> itemInfo itm ++ " It is on the floor" ++ floorItemPickupInfo n itm + Left FlIt{_flIt = itm} -> itemInfo itm ++ " It is on the floor" ++ floorItemPickupInfo n itm Right _ -> "Some sort of switch or button." floorItemPickupInfo :: Int -> Item -> String