Start simplifying tesla arcs

This commit is contained in:
2025-01-09 11:01:17 +00:00
parent c355fe4f5f
commit 5fb71cec39
6 changed files with 35 additions and 37 deletions
-2
View File
@@ -23,8 +23,6 @@ data ItemParams
, _newArcStep :: NextArcStep --ItemParams -> World -> ArcStep -> State StdGen (Maybe ArcStep) , _newArcStep :: NextArcStep --ItemParams -> World -> ArcStep -> State StdGen (Maybe ArcStep)
, _previousArcEffect :: PreviousArcEffect , _previousArcEffect :: PreviousArcEffect
} }
-- | ParamMID {_paramMID :: Maybe Int}
-- | BoostPropIX {_boostPropIX :: Maybe Int}
data ShrinkGunStatus = FullSize | Shrunk data ShrinkGunStatus = FullSize | Shrunk
--deriving (Eq, Ord, Show, Read) --Generic, Flat) --deriving (Eq, Ord, Show, Read) --Generic, Flat)
+3 -3
View File
@@ -10,11 +10,11 @@ import Control.Lens
import Data.Aeson import Data.Aeson
import Data.Aeson.TH import Data.Aeson.TH
import Dodge.Data.ArcStep import Dodge.Data.ArcStep
import Geometry.Data --import Geometry.Data
data TeslaArc = TeslaArc data TeslaArc = TeslaArc
{ _taPoints :: [Point2] -- { _taPoints :: [Point2]
, _taTimer :: Int { _taTimer :: Int
, _taArcSteps :: [ArcStep] , _taArcSteps :: [ArcStep]
, _taColor :: Color , _taColor :: Color
} }
+1 -2
View File
@@ -644,8 +644,7 @@ mcShootAuto itm mc w
-- | assumes that the item is held -- | assumes that the item is held
shootTeslaArc :: Item -> Creature -> Muzzle -> World -> World shootTeslaArc :: Item -> Creature -> Muzzle -> World -> World
shootTeslaArc itm cr mz w = shootTeslaArc itm cr mz w =
w' w' & cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itParams .~ ip
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itParams .~ ip
where where
-- use items item location instead -- use items item location instead
itRef = cr ^?! crManipulation . manObject . imRootSelectedItem -- unsafe!! TODO change itRef = cr ^?! crManipulation . manObject . imRootSelectedItem -- unsafe!! TODO change
+6 -6
View File
@@ -209,11 +209,11 @@ pjRemoteSetDirection ph pj w = case ph of
.~ 0.5 * diffAngles ((w ^. wCam . camRot) + argV (w ^. input . mousePos)) (_pjDir pj) .~ 0.5 * diffAngles ((w ^. wCam . camRot) + argV (w ^. input . mousePos)) (_pjDir pj)
Just (HomeUsingTargeting itid) Just (HomeUsingTargeting itid)
| Just tp <- w ^? pointerToItemID itid . itTargeting . itTgPos . _Just -> | Just tp <- w ^? pointerToItemID itid . itTargeting . itTgPos . _Just ->
w & cWorld . lWorld . projectiles . ix (_pjID pj) . pjDir w
%~ turnTo 0.2 (_pjPos pj) tp & cWorld . lWorld . projectiles . ix (_pjID pj) . pjDir
& cWorld . lWorld . projectiles . ix (_pjID pj) . pjSpin %~ turnTo 0.2 (_pjPos pj) tp
& cWorld . lWorld . projectiles . ix (_pjID pj) . pjSpin
.~ 0.5 * diffAngles (turnTo 0.2 (_pjPos pj) tp (_pjDir pj)) (_pjDir pj) .~ 0.5 * diffAngles (turnTo 0.2 (_pjPos pj) tp (_pjDir pj)) (_pjDir pj)
_ -> w _ -> w
where where
lw = w ^. cWorld . lWorld lw = w ^. cWorld . lWorld
@@ -239,8 +239,8 @@ moveProjectile pj w
w w
& cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjSpin *~ 0.99 & cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjSpin *~ 0.99
& cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjPos +~ _pjVel pj & cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjPos +~ _pjVel pj
& cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjDir +~ & cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjDir
(_pjSpin pj * _pjSpinFactor pj) +~ (_pjSpin pj * _pjSpinFactor pj)
explodeShell :: explodeShell ::
Projectile -> Projectile ->
+23 -23
View File
@@ -20,35 +20,35 @@ import Picture
import RandomHelp import RandomHelp
import Shape import Shape
updateTeslaArc :: updateTeslaArc :: World -> TeslaArc -> (World, Maybe TeslaArc)
World ->
TeslaArc ->
(World, Maybe TeslaArc)
updateTeslaArc w pt updateTeslaArc w pt
| _taTimer pt == 2 = | _taTimer pt == 2 =
( makesparks $ foldl' (flip damthings) w thearc ( makesparks $ foldl' (flip damthings) w thearc
, Just $ pt & taTimer -~ 1 , Just $ pt & taTimer -~ 1
) )
| _taTimer pt < 0 = (w, Nothing) | _taTimer pt >= 0 = (w, Just $ pt & taTimer -~ 1)
| otherwise = (w, Just $ pt & taTimer -~ 1) | otherwise = (w, Nothing)
where where
thearc = _taArcSteps pt thearc = _taArcSteps pt
rcol = brightX 100 1.5 <$> takeOne [white, azure, blue, cyan] makeaspark =
rspeed = state (randomR (3, 6)) randSpark
makeaspark = randSpark ELECTRICAL rspeed rcol rdir lp ELECTRICAL
(state (randomR (3, 6)))
(brightX 100 1.5 <$> takeOne [white, azure, blue, cyan])
rdir
lp
makesparks = makeaspark . makeaspark . makeaspark makesparks = makeaspark . makeaspark . makeaspark
rp x = randPeakedParam 2 (x - 0.7) x (x + 0.7) rp x = randPeakedParam 2 (x - 0.7) x (x + 0.7)
(lp, rdir) = case last thearc of (lp, rdir)
ArcStep lp' ld' NothingID -> (lp', rp ld') | ArcStep lp' ld' (CrID crid) <- last thearc
ArcStep lp' ld' (CrID crid) -> case w ^? cWorld . lWorld . creatures . ix crid of , Just cr <- w ^? cWorld . lWorld . creatures . ix crid =
Nothing -> (lp', rp ld') (lp' -.- (_crRad cr + 1) *.* unitVectorAtAngle ld', rp $ ld' + pi)
Just cr -> (lp' -.- (_crRad cr + 1) *.* unitVectorAtAngle ld', rp $ ld' + pi) | ArcStep lp' ld' (WlID wlid) <- last thearc
ArcStep lp' ld' (WlID wlid) -> case w ^? cWorld . lWorld . walls . ix wlid of , Just wl <- w ^? cWorld . lWorld . walls . ix wlid =
Nothing -> (lp', rp ld') ( lp' -.- 2 *.* unitVectorAtAngle ld'
Just wl -> , randWallReflect ld' wl
( lp' -.- 2 *.* unitVectorAtAngle ld' )
, randWallReflect ld' wl | ArcStep lp' ld' _ <- last thearc = (lp', rp ld')
)
damthings (ArcStep p dir crwl) = damageCrWlID (thedamage p dir) crwl damthings (ArcStep p dir crwl) = damageCrWlID (thedamage p dir) crwl
thedamage p dir = Damage ELECTRICAL 50 (p -.- q) p (p +.+ q) NoDamageEffect thedamage p dir = Damage ELECTRICAL 50 (p -.- q) p (p +.+ q) NoDamageEffect
where where
@@ -67,8 +67,8 @@ makeTeslaArc ip pos dir w =
( w & randGen .~ g ( w & randGen .~ g
& cWorld . lWorld . teslaArcs & cWorld . lWorld . teslaArcs
.:~ TeslaArc .:~ TeslaArc
{ _taPoints = map (^. asPos) newarc --{ _taPoints = map (^. asPos) newarc
, _taArcSteps = newarc { _taArcSteps = newarc
, _taTimer = 2 , _taTimer = 2
, _taColor = brightX 100 1.5 col , _taColor = brightX 100 1.5 col
} }
@@ -97,7 +97,7 @@ updateArc ::
updateArc ip w p dir = take (_arcNumber ip) <$> zipArcs ip w (ArcStep p dir NothingID) carc updateArc ip w p dir = take (_arcNumber ip) <$> zipArcs ip w (ArcStep p dir NothingID) carc
where where
carc = case _currentArc ip of carc = case _currentArc ip of
(_:xs) -> xs (_ : xs) -> xs
[] -> [] -- tail $ _currentArc ip [] -> [] -- tail $ _currentArc ip
zipArcs :: zipArcs ::
+2 -1
View File
@@ -4,6 +4,7 @@ module Dodge.Tesla.Draw (
import Picture.Base import Picture.Base
import Dodge.Data.TeslaArc import Dodge.Data.TeslaArc
import Dodge.Data.ArcStep
import Control.Lens import Control.Lens
drawTeslaArc :: TeslaArc -> Picture drawTeslaArc :: TeslaArc -> Picture
@@ -17,4 +18,4 @@ drawTeslaArc pt =
x | pt ^. taTimer > 0 = 3 x | pt ^. taTimer > 0 = 3
| pt ^. taTimer >= 0 = 2 | pt ^. taTimer >= 0 = 2
| otherwise = 0.5 | otherwise = 0.5
ps = _taPoints pt ps = pt ^.. taArcSteps . each . asPos