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