This commit is contained in:
2024-12-24 21:25:23 +00:00
parent 81fd2131e0
commit 18b569ac89
4 changed files with 29 additions and 27 deletions
+2 -2
View File
@@ -1,8 +1,8 @@
{ {
"_debug_booleans": [ "_debug_booleans": [
"Show_ms_frame", "Show_ms_frame",
"Show_sound", "Enable_debug",
"Select_creature" "Collision_test"
], ],
"_debug_view_clip_bounds": "NoRoomClipBoundaries", "_debug_view_clip_bounds": "NoRoomClipBoundaries",
"_gameplay_rotate_to_wall": true, "_gameplay_rotate_to_wall": true,
-2
View File
@@ -12,13 +12,11 @@ defaultBullet =
Bullet Bullet
{ _buEffect = DestroyBullet { _buEffect = DestroyBullet
, _buPayload = BulSpark , _buPayload = BulSpark
-- , _buTrajectory = BasicBulletTrajectory
, _buVel = V2 50 0 , _buVel = V2 50 0
, _buDrag = 1 , _buDrag = 1
, _buPos = 0 , _buPos = 0
, _buOldPos = 0 , _buOldPos = 0
, _buWidth = 2 , _buWidth = 2
-- , _buTimer = 100
, _buDamages = basicBulDams , _buDamages = basicBulDams
} }
+26 -22
View File
@@ -1,24 +1,24 @@
--{-# OPTIONS_GHC -Wno-unused-imports #-} --{-# OPTIONS_GHC -Wno-unused-imports #-}
module Dodge.Projectile.Update module Dodge.Projectile.Update (
( updateProjectile updateProjectile,
) where ) where
import Control.Monad
import Dodge.Movement.Turn
import NewInt
import Dodge.Payload
import Control.Lens import Control.Lens
import Control.Monad
import Data.Foldable
import Data.Maybe import Data.Maybe
import Dodge.Base import Dodge.Base
import Dodge.Data.World import Dodge.Data.World
import Dodge.EnergyBall import Dodge.EnergyBall
import Dodge.Item.Location import Dodge.Item.Location
import Dodge.Movement.Turn
import Dodge.Payload
import Dodge.SoundLogic import Dodge.SoundLogic
import Dodge.WorldEvent.Cloud import Dodge.WorldEvent.Cloud
import Geometry import Geometry
import qualified IntMapHelp as IM import qualified IntMapHelp as IM
import NewInt
import RandomHelp import RandomHelp
import Data.Foldable
updateProjectile :: Projectile -> World -> World updateProjectile :: Projectile -> World -> World
updateProjectile pj w = foldl' (\w' pu -> upProjectile pu pj w') w (_prjUpdates pj) updateProjectile pj w = foldl' (\w' pu -> upProjectile pu pj w') w (_prjUpdates pj)
@@ -38,16 +38,16 @@ upProjectile pu pj = case pu of
| otherwise -> id | otherwise -> id
ReduceSpinPU x -> reduceSpinBy x (_prjID pj) ReduceSpinPU x -> reduceSpinBy x (_prjID pj)
DestroyPU mitid 0 -> destroyProjectile mitid (_prjID pj) DestroyPU mitid 0 -> destroyProjectile mitid (_prjID pj)
-- the following requires that this is at the top of the update list, which is -- the following requires that this is at the top of the update list, which is
-- not ideal -- not ideal
DestroyPU _ _ -> cWorld . lWorld . projectiles . ix (_prjID pj) . prjUpdates . ix 0 . pjuTimer -~ 1 DestroyPU _ _ -> cWorld . lWorld . projectiles . ix (_prjID pj) . prjUpdates . ix 0 . pjuTimer -~ 1
where where
time = _prjTimer pj time = _prjTimer pj
act st et = time <= st && time >= et act st et = time <= st && time >= et
shellCollisionEffect :: Maybe (NewInt ItmInt) -> Projectile -> World -> World shellCollisionEffect :: Maybe (NewInt ItmInt) -> Projectile -> World -> World
shellCollisionEffect mscreenid = shellCollisionCheck shellCollisionEffect mscreenid = shellCollisionCheck $
$ \pj -> explodeShell mscreenid (_prjID pj) \pj -> explodeShell mscreenid (_prjID pj)
shellCollisionCheck :: (Projectile -> World -> World) -> Projectile -> World -> World shellCollisionCheck :: (Projectile -> World -> World) -> Projectile -> World -> World
shellCollisionCheck f pj w shellCollisionCheck f pj w
@@ -61,8 +61,9 @@ shellCollisionCheck f pj w
newPos = oldPos +.+ _prjVel pj newPos = oldPos +.+ _prjVel pj
destroyProjectile :: Maybe (NewInt ItmInt) -> Int -> World -> World destroyProjectile :: Maybe (NewInt ItmInt) -> Int -> World -> World
destroyProjectile mitid pjid w = w & cWorld . lWorld . projectiles %~ IM.delete pjid destroyProjectile mitid pjid w =
& removelink w & cWorld . lWorld . projectiles %~ IM.delete pjid
& removelink
where where
removelink = fromMaybe id $ do removelink = fromMaybe id $ do
itid <- fmap _unNInt mitid itid <- fmap _unNInt mitid
@@ -70,7 +71,7 @@ destroyProjectile mitid pjid w = w & cWorld . lWorld . projectiles %~ IM.delete
itm <- w ^? pointerToItemLocation loc . itUse . uaParams . apLinkedProjectile . _Just itm <- w ^? pointerToItemLocation loc . itUse . uaParams . apLinkedProjectile . _Just
guard $ itm == pjid guard $ itm == pjid
return $ pointerToItemLocation loc . itUse . uaParams . apLinkedProjectile .~ Nothing return $ pointerToItemLocation loc . itUse . uaParams . apLinkedProjectile .~ Nothing
doThrust :: Projectile -> World -> World doThrust :: Projectile -> World -> World
doThrust pj w = doThrust pj w =
w w
@@ -78,7 +79,9 @@ doThrust pj w =
& cWorld . lWorld . projectiles . ix i . prjVel %~ (\v -> accel +.+ frict *.* v) & cWorld . lWorld . projectiles . ix i . prjVel %~ (\v -> accel +.+ frict *.* v)
& soundContinue (ShellSound i) newPos missileLaunchS (Just 1) & soundContinue (ShellSound i) newPos missileLaunchS (Just 1)
& makeFlamelet (oldPos -.- vel) (vel +.+ rotateV (pi + sparkD) accel) 3 10 & makeFlamelet (oldPos -.- vel) (vel +.+ rotateV (pi + sparkD) accel) 3 10
& shellTrailCloud trailage trailfadetime & shellTrailCloud
trailage
trailfadetime
(addZ 20 (oldPos +.+ r1 +.+ 30 *.* normalizeV (oldPos -.- newPos))) (addZ 20 (oldPos +.+ r1 +.+ 30 *.* normalizeV (oldPos -.- newPos)))
where where
trailage = fst . randomR (300, 500) $ _randGen w trailage = fst . randomR (300, 500) $ _randGen w
@@ -116,16 +119,17 @@ pjRemoteSetDirection ph pj w = case ph of
HomeUsingRemoteScreen screenid -> HomeUsingRemoteScreen screenid ->
let newdir let newdir
| w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . imSelectedItem | w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . imSelectedItem
== w ^? cWorld . lWorld . itemLocations . ix (_unNInt screenid) . ilInvID == w ^? cWorld . lWorld . itemLocations . ix (_unNInt screenid) . ilInvID =
= (w ^. wCam . camRot) + argV (_mousePos (_input w)) (w ^. wCam . camRot) + argV (_mousePos (_input w))
| otherwise = _prjDir pj | otherwise = _prjDir pj
in w & cWorld . lWorld . projectiles . ix (_prjID pj) . prjAcc in w & cWorld . lWorld . projectiles . ix (_prjID pj) . prjAcc
.~ magV (_prjAcc pj) *.* unitVectorAtAngle newdir .~ magV (_prjAcc pj) *.* unitVectorAtAngle newdir
HomeUsingTargeting itid -> fromMaybe w $ do HomeUsingTargeting itid -> fromMaybe w $ do
tp <- w ^? pointerToItemID itid . itTargeting . itTgPos . _Just tp <- w ^? pointerToItemID itid . itTargeting . itTgPos . _Just
return $ w & cWorld . lWorld . projectiles . ix (_prjID pj) . prjAcc return $
w & cWorld . lWorld . projectiles . ix (_prjID pj) . prjAcc
%~ vecTurnTo 0.2 (_prjPos pj) tp %~ vecTurnTo 0.2 (_prjPos pj) tp
--pjRemoteSetDirection mscreenid pj w = fromMaybe w $ do --pjRemoteSetDirection mscreenid pj w = fromMaybe w $ do
-- screenid <- fmap _unNInt mscreenid -- screenid <- fmap _unNInt mscreenid
-- let newdir -- let newdir
@@ -159,5 +163,5 @@ explodeShell mitid pjid w =
& usePayload (_prjPayload thepj) (_prjPos thepj) (_prjVel thepj) & usePayload (_prjPayload thepj) (_prjPos thepj) (_prjVel thepj)
& stopSoundFrom (ShellSound pjid) & stopSoundFrom (ShellSound pjid)
where where
-- itPoint = pointerToItemLocation $ w ^?! cWorld . lWorld . itemLocations . ix itid-- _itemLocations (_cWorld w) IM.! itid -- itPoint = pointerToItemLocation $ w ^?! cWorld . lWorld . itemLocations . ix itid-- _itemLocations (_cWorld w) IM.! itid
thepj = w ^?! cWorld . lWorld . projectiles . ix pjid thepj = w ^?! cWorld . lWorld . projectiles . ix pjid
+1 -1
View File
@@ -26,7 +26,7 @@ import qualified IntMapHelp as IM
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
testStringInit :: Universe -> [String] testStringInit :: Universe -> [String]
testStringInit _ = [] testStringInit u = foldMap prettyShort $ u ^. uvWorld . cWorld . lWorld . projectiles
-- (map (show . _ebPos) $ u ^. uvWorld . cWorld . lWorld . energyBalls) -- (map (show . _ebPos) $ u ^. uvWorld . cWorld . lWorld . energyBalls)
-- <> -- <>
-- (foldMap prettyShort $ u ^. uvWorld . cWorld . lWorld . bullets) -- (foldMap prettyShort $ u ^. uvWorld . cWorld . lWorld . bullets)