Commit before improving item targeting
This commit is contained in:
@@ -183,7 +183,6 @@ testInventory = IM.fromList $ zip [0..]
|
||||
stackedInventory :: IM.IntMap Item
|
||||
stackedInventory = IM.fromList $ zip [0..]
|
||||
[sonicGun
|
||||
,teleGun
|
||||
,spreadGun
|
||||
, pipe
|
||||
,rewindGun
|
||||
|
||||
@@ -41,7 +41,7 @@ lampCrPic h = pictures
|
||||
, concatMap (polyToTris . map f) $ boxXYZnobase 5 5 (h-1)
|
||||
]
|
||||
where
|
||||
f pos = Verx (pos -.-.- V3 2.5 2.5 0) blue [] 0 polyNum
|
||||
f pos = Verx (pos -.-.- V3 2.5 2.5 0) blue [] (LayNum 0) polyNum
|
||||
|
||||
initialiseLamp :: Float -> Creature -> World -> World
|
||||
initialiseLamp = initialiseColorLamp 0.75
|
||||
|
||||
+18
-1
@@ -320,7 +320,7 @@ data FloorItem = FlIt { _flIt :: Item , _flItPos :: Point2 , _flItRot :: Float,
|
||||
data ItemPos
|
||||
= InInv { _itCrId :: Int , _itInvId :: Int }
|
||||
| OnFloor { _itFlID :: Int }
|
||||
data ItemUse
|
||||
data ItemUse
|
||||
= RightUse
|
||||
{ _rUse :: Item -> Creature -> World -> World
|
||||
, _useDelay :: UseDelay
|
||||
@@ -377,6 +377,13 @@ data Item = Item
|
||||
, _itModules :: M.Map ModuleSlot ItemModule
|
||||
, _itScope :: Scope
|
||||
}
|
||||
data Targeting
|
||||
= NoTargeting
|
||||
| Targeting
|
||||
{ _tgPos :: Maybe Point2
|
||||
, _tgUpdate :: Item -> Creature -> World -> Maybe Point2
|
||||
, _tgDraw :: Item -> Creature -> World -> Picture
|
||||
}
|
||||
data ModuleSlot
|
||||
= ModBullet
|
||||
| ModRifleMag
|
||||
@@ -620,6 +627,15 @@ data Prop
|
||||
, _prDraw :: Prop -> SPic
|
||||
, _prToggle :: Bool
|
||||
}
|
||||
| RemoteShell
|
||||
{ _pjPos :: Point2
|
||||
, _pjStartPos :: Point2
|
||||
, _pjVel :: Point2
|
||||
, _prDraw :: Prop -> SPic
|
||||
, _pjID :: Int
|
||||
, _pjUpdate :: Prop -> World -> World
|
||||
, _pjPayload :: Point2 -> World -> World
|
||||
}
|
||||
| Shell
|
||||
{ _pjPos :: Point2
|
||||
, _pjStartPos :: Point2
|
||||
@@ -933,3 +949,4 @@ makeLenses ''Magnet
|
||||
makeLenses ''Gust
|
||||
makeLenses ''GunBarrels
|
||||
makeLenses ''ItemModule
|
||||
makeLenses ''Targeting
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
module Dodge.Item.Weapon.Bezier
|
||||
( bezierGun
|
||||
, teleGun
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Base
|
||||
@@ -47,7 +46,6 @@ bezierGun = defaultGun
|
||||
{ _ammoBaseMax = 15
|
||||
}
|
||||
}
|
||||
|
||||
shootBezier :: Point2 -> Creature -> World -> World
|
||||
shootBezier targetp cr w = w & particles .:~ aCurveBulAt
|
||||
(Just cid)
|
||||
@@ -66,6 +64,3 @@ shootBezier targetp cr w = w & particles .:~ aCurveBulAt
|
||||
a <- randInCirc 10
|
||||
b <- randInCirc 20
|
||||
return (a,b)
|
||||
|
||||
teleGun :: Item
|
||||
teleGun = bezierGun
|
||||
|
||||
@@ -291,19 +291,4 @@ remoteBombUnarmedPic :: Picture
|
||||
remoteBombUnarmedPic = color (dark $ dark orange) $ circleSolid 5
|
||||
|
||||
retireRemoteBomb :: Int -> Int -> Int -> World -> World
|
||||
retireRemoteBomb itid 0 pjid w = w
|
||||
& pointToItem (_itemPositions w IM.! itid) %~
|
||||
( (itScope . scopePos .~ V2 0 0)
|
||||
-- . (itZoom .~ defaultItZoom)
|
||||
. (itUse . rUse .~ const throwRemoteBomb)
|
||||
)
|
||||
& props %~ IM.delete pjid
|
||||
retireRemoteBomb itid t pjid w = setScope w
|
||||
& props . ix pjid . pjUpdate .~ (\_ -> retireRemoteBomb itid (t-1) pjid)
|
||||
where
|
||||
setScope w' = case _itemPositions w' IM.! itid of
|
||||
InInv cid invid -> w'
|
||||
& creatures . ix cid . crInv . ix invid . itScope
|
||||
. scopePos .~ (pos -.- _crPos (_creatures w' IM.! cid))
|
||||
_ -> w'
|
||||
pos = fromMaybe (V2 0 0) $ w ^? props . ix pjid . pjPos
|
||||
retireRemoteBomb = retireRemoteProj $ const throwRemoteBomb
|
||||
|
||||
@@ -408,19 +408,7 @@ remoteShellPic t
|
||||
col | t > (-99) = green
|
||||
| otherwise = red
|
||||
retireRemoteRocket :: Int -> Int -> Int -> World -> World
|
||||
retireRemoteRocket itid 0 pjid w =
|
||||
set (pointToItem (_itemPositions w IM.! itid) . itScope . scopePos) (V2 0 0)
|
||||
$ set (pointToItem (_itemPositions w IM.! itid) . itUse . rUse) (const fireRemoteLauncher)
|
||||
(w & props %~ IM.delete pjid)
|
||||
retireRemoteRocket itid t pjid w = setScope w
|
||||
& props . ix pjid . pjUpdate .~ (\_ -> retireRemoteRocket itid (t-1) pjid)
|
||||
where
|
||||
setScope w' = case _itemPositions w' IM.! itid of
|
||||
InInv cid invid -> w'
|
||||
& creatures . ix cid . crInv . ix invid . itScope
|
||||
. scopePos .~ (pos -.- _crPos (_creatures w' IM.! cid))
|
||||
_ -> w'
|
||||
pos = fromMaybe (V2 0 0) $ w ^? props . ix pjid . pjPos
|
||||
retireRemoteRocket = retireRemoteProj $ const fireRemoteLauncher
|
||||
|
||||
setRemoteScope :: Int -> Prop -> World -> World
|
||||
setRemoteScope itid pj w' = case w' ^? itemPositions . ix itid of
|
||||
|
||||
@@ -1,11 +1,33 @@
|
||||
module Dodge.Item.Weapon.Remote
|
||||
( pointToItem
|
||||
, retireRemoteProj
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Geometry
|
||||
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Control.Lens
|
||||
import Data.Maybe
|
||||
|
||||
pointToItem :: Applicative f =>
|
||||
ItemPos -> (Item -> f Item) -> World -> f World
|
||||
pointToItem (InInv cid invid) = creatures . ix cid . crInv . ix invid
|
||||
pointToItem (OnFloor flid) = floorItems . ix flid . flIt
|
||||
|
||||
retireRemoteProj :: (Item -> Creature -> World -> World)
|
||||
-> Int -> Int -> Int -> World -> World
|
||||
retireRemoteProj resetFire itid 0 pjid w = w
|
||||
& pointToItem (_itemPositions w IM.! itid) %~
|
||||
( (itScope . scopePos .~ V2 0 0)
|
||||
. (itUse . rUse .~ resetFire)
|
||||
)
|
||||
& props %~ IM.delete pjid
|
||||
retireRemoteProj resetFire itid t pjid w = setScope w
|
||||
& props . ix pjid . pjUpdate .~ (\_ -> retireRemoteProj resetFire itid (t-1) pjid)
|
||||
where
|
||||
setScope w' = case _itemPositions w' IM.! itid of
|
||||
InInv cid invid -> w'
|
||||
& creatures . ix cid . crInv . ix invid . itScope
|
||||
. scopePos .~ (pos -.- _crPos (_creatures w' IM.! cid))
|
||||
_ -> w'
|
||||
pos = fromMaybe (V2 0 0) $ w ^? props . ix pjid . pjPos
|
||||
|
||||
@@ -2,14 +2,15 @@ module Dodge.Particle.Bullet.Spawn
|
||||
( aGenBulAt
|
||||
, aDelayedBulAt
|
||||
, aCurveBulAt
|
||||
, accelBulAt
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Particle.Bullet.Draw
|
||||
import Dodge.Particle.Bullet.Update
|
||||
import Geometry
|
||||
import Picture
|
||||
import LensHelp
|
||||
|
||||
import Control.Lens
|
||||
import Data.Bifunctor
|
||||
|
||||
aGenBulAt
|
||||
@@ -80,3 +81,27 @@ aCurveBulAt maycid col pos control targ hiteff width = BulletPt
|
||||
where
|
||||
setVel pt = pt & ptVel .~ bf (fromIntegral $ _ptTimer pt - 1) -.- bf (fromIntegral $ _ptTimer pt)
|
||||
bf t = bQuadToF (pos,control,targ) $ (100 - t) * 0.05
|
||||
|
||||
accelBulAt
|
||||
:: Maybe Int -- ^ Pass-through creature id
|
||||
-> Color
|
||||
-> Point2 -- ^ Start position
|
||||
-> Point2 -- ^ Velocity
|
||||
-> Point2 -- ^ Acceleration
|
||||
-> HitEffect
|
||||
-> Float -- ^ Bullet width
|
||||
-> Particle
|
||||
accelBulAt maycid col pos vel acc hiteff width = BulletPt
|
||||
{ _ptDraw = drawBul
|
||||
, _ptUpdate = \w -> mvBullet w . setVel
|
||||
, _ptVel = vel
|
||||
, _btDrag = 1
|
||||
, _ptColor = col
|
||||
, _ptTrail = [pos]
|
||||
, _ptCrIgnore = maycid
|
||||
, _ptWidth = width
|
||||
, _ptTimer = 100
|
||||
, _ptHitEff = hiteff
|
||||
}
|
||||
where
|
||||
setVel pt = pt & ptVel .+.+~ acc
|
||||
|
||||
Reference in New Issue
Block a user