Minor tweaking, argument refining
This commit is contained in:
@@ -6,7 +6,10 @@ module Dodge.Base.Coordinate (
|
|||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Dodge.Base.WinScale
|
import Dodge.Base.WinScale
|
||||||
import Dodge.Data.Universe
|
import Dodge.Data.CamPos
|
||||||
|
import Dodge.Data.Config
|
||||||
|
import Dodge.Data.HUD
|
||||||
|
import Dodge.Data.Input
|
||||||
import Geometry
|
import Geometry
|
||||||
|
|
||||||
---- | Transform coordinates from world position to screen coordinates.
|
---- | Transform coordinates from world position to screen coordinates.
|
||||||
@@ -30,10 +33,9 @@ worldPosToScreen cam =
|
|||||||
{- | Transform coordinates from the map position to screen
|
{- | Transform coordinates from the map position to screen
|
||||||
coordinates.
|
coordinates.
|
||||||
-}
|
-}
|
||||||
cartePosToScreen :: Configuration -> World -> Point2 -> Point2
|
cartePosToScreen :: Configuration -> HUD -> Point2 -> Point2
|
||||||
cartePosToScreen cfig w = doWindowScale cfig . doRotate . doZoom . doTranslate
|
cartePosToScreen cfig thehud = doWindowScale cfig . doRotate . doZoom . doTranslate
|
||||||
where
|
where
|
||||||
thehud = w ^. cWorld . lWorld . hud
|
|
||||||
doTranslate p = p -.- (thehud ^. carteCenter) -- _carteCenter (_hud (_cWorld w))
|
doTranslate p = p -.- (thehud ^. carteCenter) -- _carteCenter (_hud (_cWorld w))
|
||||||
doZoom p = (thehud ^. carteZoom) *.* p
|
doZoom p = (thehud ^. carteZoom) *.* p
|
||||||
doRotate p = rotateV (negate $ thehud ^. carteRot) p
|
doRotate p = rotateV (negate $ thehud ^. carteRot) p
|
||||||
@@ -42,12 +44,10 @@ cartePosToScreen cfig w = doWindowScale cfig . doRotate . doZoom . doTranslate
|
|||||||
--crToMousePosOffset cr w = (mouseWorldPos w -.- _crPos cr, 0)
|
--crToMousePosOffset cr w = (mouseWorldPos w -.- _crPos cr, 0)
|
||||||
|
|
||||||
-- | The mouse position in world coordinates.
|
-- | The mouse position in world coordinates.
|
||||||
mouseWorldPos :: World -> Point2
|
mouseWorldPos :: Input -> CamPos -> Point2
|
||||||
mouseWorldPos w =
|
mouseWorldPos inp cam =
|
||||||
(cam ^. camCenter)
|
(cam ^. camCenter)
|
||||||
+.+ (1 / (cam ^. camZoom)) *.* rotateV (cam ^. camRot) (_mousePos $ _input w)
|
+.+ (1 / (cam ^. camZoom)) *.* rotateV (cam ^. camRot) (_mousePos inp)
|
||||||
where
|
|
||||||
cam = w ^. cWorld . lWorld . camPos
|
|
||||||
|
|
||||||
---- | The mouse position in map coordinates
|
---- | The mouse position in map coordinates
|
||||||
--mouseCartePos :: World -> Point2
|
--mouseCartePos :: World -> Point2
|
||||||
|
|||||||
+1
-1
@@ -78,7 +78,7 @@ useAmmoParams it cr w =
|
|||||||
return $ FlechetteTrajectory tpos
|
return $ FlechetteTrajectory tpos
|
||||||
BezierTrajectory{} -> fromMaybe BasicBulletTrajectory $ do
|
BezierTrajectory{} -> fromMaybe BasicBulletTrajectory $ do
|
||||||
tpos <- it ^? itTargeting . tgPos . _Just
|
tpos <- it ^? itTargeting . tgPos . _Just
|
||||||
return $ BezierTrajectory sp tpos (mouseWorldPos w)
|
return $ BezierTrajectory sp tpos (mouseWorldPos (w ^. input) (w ^. cWorld . lWorld . camPos))
|
||||||
|
|
||||||
bounceDir :: (Point2, Either Creature Wall) -> Maybe Point2
|
bounceDir :: (Point2, Either Creature Wall) -> Maybe Point2
|
||||||
bounceDir (_, Right wl) | _wlBouncy wl = Just $ uncurry (-.-) (_wlLine wl)
|
bounceDir (_, Right wl) | _wlBouncy wl = Just $ uncurry (-.-) (_wlLine wl)
|
||||||
|
|||||||
+3
-3
@@ -4,12 +4,12 @@ module Dodge.Clock (
|
|||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import qualified Data.Vector as V
|
import qualified Data.Vector as V
|
||||||
import Dodge.Data.World
|
import Dodge.Data.LWorld
|
||||||
|
|
||||||
clockCycle :: Int -> V.Vector a -> World -> a
|
clockCycle :: Int -> V.Vector a -> LWorld -> a
|
||||||
{-# INLINEABLE clockCycle #-}
|
{-# INLINEABLE clockCycle #-}
|
||||||
clockCycle tPeriod xs w = xs V.! i
|
clockCycle tPeriod xs w = xs V.! i
|
||||||
where
|
where
|
||||||
l = V.length xs
|
l = V.length xs
|
||||||
t = (w ^. cWorld . lWorld . lClock) `mod` (l * tPeriod)
|
t = (w ^. lClock) `mod` (l * tPeriod)
|
||||||
i = t `div` tPeriod
|
i = t `div` tPeriod
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ blinkActionMousePos cr w =
|
|||||||
& inverseShockwaveAt cpos 40 2 2
|
& inverseShockwaveAt cpos 40 2 2
|
||||||
where
|
where
|
||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
p1 = mouseWorldPos w
|
p1 = mouseWorldPos (w ^. input) (w ^. cWorld . lWorld . camPos)
|
||||||
cpos = _crPos cr
|
cpos = _crPos cr
|
||||||
--p2 = bouncePoint (const True) 1 cpos p1 w
|
--p2 = bouncePoint (const True) 1 cpos p1 w
|
||||||
p2 = pushIntoMaybe $ collideCircWalls cpos p1 r (wlsNearSeg cpos p1 w)
|
p2 = pushIntoMaybe $ collideCircWalls cpos p1 r (wlsNearSeg cpos p1 w)
|
||||||
@@ -70,7 +70,7 @@ unsafeBlinkAction cr w
|
|||||||
wl <- snd $ collidePointWallsFilter (const True) mwp cpos w
|
wl <- snd $ collidePointWallsFilter (const True) mwp cpos w
|
||||||
return (isLHS mwp `uncurry` _wlLine wl)
|
return (isLHS mwp `uncurry` _wlLine wl)
|
||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
mwp = mouseWorldPos w
|
mwp = mouseWorldPos (w ^. input) (w ^. cWorld . lWorld . camPos)
|
||||||
cpos = _crPos cr
|
cpos = _crPos cr
|
||||||
|
|
||||||
blinkShockwave ::
|
blinkShockwave ::
|
||||||
@@ -96,7 +96,7 @@ blinkActionFail cr w =
|
|||||||
distR = 120
|
distR = 120
|
||||||
distortionBulge = RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR) 1.9
|
distortionBulge = RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR) 1.9
|
||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
p1 = mouseWorldPos w
|
p1 = mouseWorldPos (w ^. input) (w ^. cWorld . lWorld . camPos)
|
||||||
cpos = _crPos cr
|
cpos = _crPos cr
|
||||||
p2 = bouncePoint (const True) 1 cpos p1 w
|
p2 = bouncePoint (const True) 1 cpos p1 w
|
||||||
r = 1.5 * _crRad cr
|
r = 1.5 * _crRad cr
|
||||||
|
|||||||
@@ -24,9 +24,10 @@ creatureDisplayText w cr =
|
|||||||
, \cr' -> [crDisplayAwareness cr']
|
, \cr' -> [crDisplayAwareness cr']
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
w
|
lw
|
||||||
cr
|
cr
|
||||||
where
|
where
|
||||||
|
lw = w ^. cWorld . lWorld
|
||||||
campos = w ^. cWorld . lWorld . camPos . camViewFrom
|
campos = w ^. cWorld . lWorld . camPos . camViewFrom
|
||||||
theScale = 0.15 / (w ^. cWorld . lWorld . camPos . camZoom)
|
theScale = 0.15 / (w ^. cWorld . lWorld . camPos . camZoom)
|
||||||
cpos = _crPos cr
|
cpos = _crPos cr
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ wasdWithAiming w speed cr
|
|||||||
movAbs = rotateV (w ^. cWorld . lWorld . camPos . camRot) $ normalizeV movDir
|
movAbs = rotateV (w ^. cWorld . lWorld . camPos . camRot) $ normalizeV movDir
|
||||||
isAiming = _posture (_crStance cr) == Aiming
|
isAiming = _posture (_crStance cr) == Aiming
|
||||||
mouseDir = case cr ^? crInv . ix (crSel cr) . itScope . scopePos of
|
mouseDir = case cr ^? crInv . ix (crSel cr) . itScope . scopePos of
|
||||||
Just _ -> argV $ mouseWorldPos w -.- _crPos cr
|
Just _ -> argV $ mouseWorldPos (w ^. input) (w ^. cWorld . lWorld . camPos) -.- _crPos cr
|
||||||
_ -> argV (_mousePos (_input w)) + (w ^. cWorld . lWorld . camPos . camRot)
|
_ -> argV (_mousePos (_input w)) + (w ^. cWorld . lWorld . camPos . camRot)
|
||||||
|
|
||||||
wasdM :: SDL.Scancode -> Point2
|
wasdM :: SDL.Scancode -> Point2
|
||||||
|
|||||||
@@ -348,7 +348,7 @@ useMod hm = case hm of
|
|||||||
directedTelPos it cr w = (p, a)
|
directedTelPos it cr w = (p, a)
|
||||||
where
|
where
|
||||||
p = fromMaybe (_crPos cr) $ it ^? itTargeting . tgPos . _Just
|
p = fromMaybe (_crPos cr) $ it ^? itTargeting . tgPos . _Just
|
||||||
a = argV (mouseWorldPos w -.- p)
|
a = argV (mouseWorldPos (w ^. input) (w ^. cWorld . lWorld . camPos) -.- p)
|
||||||
moddelay x = itUse . heldConsumption . laAmmoType . amBullet . buDelayFraction .~ x
|
moddelay x = itUse . heldConsumption . laAmmoType . amBullet . buDelayFraction .~ x
|
||||||
modcrpos x cr =
|
modcrpos x cr =
|
||||||
cr & crDir %~ tweenAngles x (_crOldDir cr)
|
cr & crDir %~ tweenAngles x (_crOldDir cr)
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ circleLaser it cr w
|
|||||||
| otherwise = w
|
| otherwise = w
|
||||||
where
|
where
|
||||||
cpos = _crPos cr
|
cpos = _crPos cr
|
||||||
mwp = mouseWorldPos w
|
mwp = mouseWorldPos (w ^. input) (w ^. cWorld . lWorld . camPos)
|
||||||
pos = _crPos cr +.+ rotateV dir (V2 0 (max 70 $ dist cpos mwp))
|
pos = _crPos cr +.+ rotateV dir (V2 0 (max 70 $ dist cpos mwp))
|
||||||
dir = fromIntegral (_lasCycle (_itParams it)) * pi / 1000
|
dir = fromIntegral (_lasCycle (_itParams it)) * pi / 1000
|
||||||
phasev = _phaseV . _itParams $ _crInv cr IM.! crSel cr
|
phasev = _phaseV . _itParams $ _crInv cr IM.! crSel cr
|
||||||
@@ -167,7 +167,7 @@ shootDualLaser it cr w =
|
|||||||
gap = _dbGap . _itParams $ it
|
gap = _dbGap . _itParams $ it
|
||||||
posl = pos +.+ (- gap) *.* vNormal (unitVectorAtAngle dir)
|
posl = pos +.+ (- gap) *.* vNormal (unitVectorAtAngle dir)
|
||||||
posr = pos +.+ gap *.* vNormal (unitVectorAtAngle dir)
|
posr = pos +.+ gap *.* vNormal (unitVectorAtAngle dir)
|
||||||
mwp = mouseWorldPos w
|
mwp = mouseWorldPos (w ^. input) (w ^. cWorld . lWorld . camPos)
|
||||||
mwp'
|
mwp'
|
||||||
| dist mwp (_crPos cr) < aimlength + 5 = _crPos cr +.+ (aimlength + 5) *.* unitVectorAtAngle dir
|
| dist mwp (_crPos cr) < aimlength + 5 = _crPos cr +.+ (aimlength + 5) *.* unitVectorAtAngle dir
|
||||||
| otherwise = mwp
|
| otherwise = mwp
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ targetRBCreatureUp it cr w t
|
|||||||
. filter (canseepos . _crPos)
|
. filter (canseepos . _crPos)
|
||||||
$ crsNearCirc mwp 40 w
|
$ crsNearCirc mwp 40 w
|
||||||
canseepos p = hasLOS (_crPos cr) p w
|
canseepos p = hasLOS (_crPos cr) p w
|
||||||
mwp = mouseWorldPos w
|
mwp = mouseWorldPos (w ^. input) (w ^. cWorld . lWorld . camPos)
|
||||||
updatePos t' = t' & tgPos .~ posFromMaybeID (_tgID t')
|
updatePos t' = t' & tgPos .~ posFromMaybeID (_tgID t')
|
||||||
posFromMaybeID Nothing = Nothing
|
posFromMaybeID Nothing = Nothing
|
||||||
posFromMaybeID (Just i) = w ^? cWorld . lWorld . creatures . ix i . crPos
|
posFromMaybeID (Just i) = w ^? cWorld . lWorld . creatures . ix i . crPos
|
||||||
@@ -107,7 +107,7 @@ targetCursorUpdate :: World -> Targeting -> Targeting
|
|||||||
targetCursorUpdate w t
|
targetCursorUpdate w t
|
||||||
| SDL.ButtonRight `M.member` _mouseButtons (_input w) =
|
| SDL.ButtonRight `M.member` _mouseButtons (_input w) =
|
||||||
t
|
t
|
||||||
& tgPos . _Just .~ mouseWorldPos w
|
& tgPos . _Just .~ mouseWorldPos (w ^. input) (w ^. cWorld . lWorld . camPos)
|
||||||
& tgActive .~ True
|
& tgActive .~ True
|
||||||
| otherwise =
|
| otherwise =
|
||||||
t & tgPos %~ const Nothing
|
t & tgPos %~ const Nothing
|
||||||
@@ -117,7 +117,7 @@ targetRBPressUpdate :: World -> Targeting -> Targeting
|
|||||||
targetRBPressUpdate w t
|
targetRBPressUpdate w t
|
||||||
| SDL.ButtonRight `M.member` _mouseButtons (_input w) =
|
| SDL.ButtonRight `M.member` _mouseButtons (_input w) =
|
||||||
t
|
t
|
||||||
& tgPos %~ maybe (Just $ mouseWorldPos w) Just
|
& tgPos %~ maybe (Just $ mouseWorldPos (w ^. input) (w ^. cWorld . lWorld . camPos)) Just
|
||||||
& tgActive .~ True
|
& tgActive .~ True
|
||||||
| otherwise =
|
| otherwise =
|
||||||
t & tgPos %~ const Nothing
|
t & tgPos %~ const Nothing
|
||||||
@@ -139,7 +139,7 @@ targetLaserUpdate _ cr w t
|
|||||||
where
|
where
|
||||||
(mp, _) = reflectLaserAlong 0.2 sp ep w
|
(mp, _) = reflectLaserAlong 0.2 sp ep w
|
||||||
sp = _crPos cr +.+ 15 *.* unitVectorAtAngle (_crDir cr)
|
sp = _crPos cr +.+ 15 *.* unitVectorAtAngle (_crDir cr)
|
||||||
ep = sp +.+ 5000 *.* normalizeV (mouseWorldPos w -.- sp)
|
ep = sp +.+ 5000 *.* normalizeV (mouseWorldPos (w ^. input) (w ^. cWorld . lWorld . camPos) -.- sp)
|
||||||
addLaserPic =
|
addLaserPic =
|
||||||
cWorld . lWorld . lasers
|
cWorld . lWorld . lasers
|
||||||
.:~ LaserStart
|
.:~ LaserStart
|
||||||
|
|||||||
@@ -698,12 +698,12 @@ duplicateOffsetsFocus xs eff item cr w = foldr f w poss
|
|||||||
& crPos %~ (+.+ pos)
|
& crPos %~ (+.+ pos)
|
||||||
& crDir .~ thedir pos
|
& crDir .~ thedir pos
|
||||||
thedir pos
|
thedir pos
|
||||||
| dist (mouseWorldPos w) (_crPos cr) < aimingMuzzlePos cr item =
|
| dist (mouseWorldPos (w ^. input) (w ^. cWorld . lWorld . camPos)) (_crPos cr) < aimingMuzzlePos cr item =
|
||||||
argV
|
argV
|
||||||
( _crPos cr +.+ aimingMuzzlePos cr item *.* unitVectorAtAngle (_crDir cr)
|
( _crPos cr +.+ aimingMuzzlePos cr item *.* unitVectorAtAngle (_crDir cr)
|
||||||
-.- (_crPos cr +.+ pos)
|
-.- (_crPos cr +.+ pos)
|
||||||
)
|
)
|
||||||
| otherwise = argV (mouseWorldPos w -.- (_crPos cr +.+ pos))
|
| otherwise = argV (mouseWorldPos (w ^. input) (w ^. cWorld . lWorld . camPos) -.- (_crPos cr +.+ pos))
|
||||||
|
|
||||||
duplicateItem :: (Item -> [Item]) -> ChainEffect
|
duplicateItem :: (Item -> [Item]) -> ChainEffect
|
||||||
duplicateItem fit eff itm cr w = foldr f w (fit itm)
|
duplicateItem fit eff itm cr w = foldr f w (fit itm)
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ unsafeBlinkGun =
|
|||||||
useForceFieldGun :: Item -> Creature -> World -> World
|
useForceFieldGun :: Item -> Creature -> World -> World
|
||||||
useForceFieldGun itm cr w = fromMaybe w $ do
|
useForceFieldGun itm cr w = fromMaybe w $ do
|
||||||
a <- _tgPos $ _itTargeting itm
|
a <- _tgPos $ _itTargeting itm
|
||||||
let mwp = mouseWorldPos w
|
let mwp = mouseWorldPos (w ^. input) (w ^. cWorld . lWorld . camPos)
|
||||||
b = if dist a mwp < 100 then mwp else a +.+ 100 *.* normalizeV (mwp -.- a)
|
b = if dist a mwp < 100 then mwp else a +.+ 100 *.* normalizeV (mwp -.- a)
|
||||||
wlline = (a, b)
|
wlline = (a, b)
|
||||||
return $
|
return $
|
||||||
|
|||||||
+1
-1
@@ -98,7 +98,7 @@ boostPoint x cr w = case mayp2 of
|
|||||||
where
|
where
|
||||||
cpos = _crPos cr
|
cpos = _crPos cr
|
||||||
r = 1.5 * _crRad cr
|
r = 1.5 * _crRad cr
|
||||||
p1 = cpos +.+ x *.* squashNormalizeV (mouseWorldPos w -.- cpos)
|
p1 = cpos +.+ x *.* squashNormalizeV (mouseWorldPos (w ^. input) (w ^. cWorld . lWorld . camPos) -.- cpos)
|
||||||
mayp2 = bouncePoint (const True) 1 cpos p1 w
|
mayp2 = bouncePoint (const True) 1 cpos p1 w
|
||||||
|
|
||||||
addBoostShockwave ::
|
addBoostShockwave ::
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ subInventoryDisplay subinv cfig w = case subinv of
|
|||||||
, invHead cfig "TWEAK"
|
, invHead cfig "TWEAK"
|
||||||
, listPicturesAt subInvX 60 cfig $ map text (ammoTweakStrings it)
|
, listPicturesAt subInvX 60 cfig $ map text (ammoTweakStrings it)
|
||||||
]
|
]
|
||||||
DisplayTerminal tid -> displayTerminal tid cfig w
|
DisplayTerminal tid -> displayTerminal tid cfig (w ^. cWorld . lWorld)
|
||||||
CombineInventory mi ->
|
CombineInventory mi ->
|
||||||
pictures
|
pictures
|
||||||
[ invHead cfig "COMBINE"
|
[ invHead cfig "COMBINE"
|
||||||
@@ -160,9 +160,9 @@ itmInfo mit = fromMaybe [] $ do
|
|||||||
itm <- mit
|
itm <- mit
|
||||||
return (map show . M.assocs . _iyModules $ _itType itm)
|
return (map show . M.assocs . _iyModules $ _itType itm)
|
||||||
|
|
||||||
displayTerminal :: Int -> Configuration -> World -> Picture
|
displayTerminal :: Int -> Configuration -> LWorld -> Picture
|
||||||
displayTerminal tid cfig w = fromMaybe mempty $ do
|
displayTerminal tid cfig w = fromMaybe mempty $ do
|
||||||
tm <- w ^? cWorld . lWorld . terminals . ix tid
|
tm <- w ^? terminals . ix tid
|
||||||
return $
|
return $
|
||||||
pictures
|
pictures
|
||||||
[ invHead cfig (_tmTitle tm ++ ":T" ++ show tid)
|
[ invHead cfig (_tmTitle tm ++ ":T" ++ show tid)
|
||||||
@@ -334,7 +334,7 @@ drawCarte cfig w =
|
|||||||
where
|
where
|
||||||
iPos = w ^. cWorld . lWorld . selLocation
|
iPos = w ^. cWorld . lWorld . selLocation
|
||||||
locs = map (\(_, s) -> (s, white)) . IM.elems . _seenLocations . _lWorld $ _cWorld w
|
locs = map (\(_, s) -> (s, white)) . IM.elems . _seenLocations . _lWorld $ _cWorld w
|
||||||
locPoss = map (cartePosToScreen cfig w . ($ w) . doWorldPos . fst) . IM.elems . _seenLocations . _lWorld $ _cWorld w
|
locPoss = map (cartePosToScreen cfig (w ^. cWorld . lWorld . hud) . ($ w) . doWorldPos . fst) . IM.elems . _seenLocations . _lWorld $ _cWorld w
|
||||||
locTexts = map fst locs
|
locTexts = map fst locs
|
||||||
|
|
||||||
displayListEndCoords :: Configuration -> [String] -> [Point2]
|
displayListEndCoords :: Configuration -> [String] -> [Point2]
|
||||||
@@ -348,12 +348,12 @@ displayListEndCoords cfig ss = map (doWindowScale cfig) $ zipWith h ss $ map f [
|
|||||||
mapOverlay :: Configuration -> World -> [Picture]
|
mapOverlay :: Configuration -> World -> [Picture]
|
||||||
mapOverlay cfig w =
|
mapOverlay cfig w =
|
||||||
(color (withAlpha 0.5 black) . polygon $ reverse $ rectNSWE 1 (-1) 1 (-1)) :
|
(color (withAlpha 0.5 black) . polygon $ reverse $ rectNSWE 1 (-1) 1 (-1)) :
|
||||||
(mapMaybe (mapWall cfig w) . IM.elems $ w ^. cWorld . lWorld . walls)
|
(mapMaybe (mapWall cfig (w ^. cWorld . lWorld . hud)) . IM.elems $ w ^. cWorld . lWorld . walls)
|
||||||
|
|
||||||
mapWall :: Configuration -> World -> Wall -> Maybe Picture
|
mapWall :: Configuration -> HUD -> Wall -> Maybe Picture
|
||||||
mapWall cfig w wl =
|
mapWall cfig thehud wl =
|
||||||
if _wlSeen wl
|
if _wlSeen wl
|
||||||
then Just . color c . polygon $ map (cartePosToScreen cfig w) [x, x +.+ n2, y +.+ n2, y]
|
then Just . color c . polygon $ map (cartePosToScreen cfig thehud) [x, x +.+ n2, y +.+ n2, y]
|
||||||
else Nothing
|
else Nothing
|
||||||
where
|
where
|
||||||
t = normalizeV (y -.- x)
|
t = normalizeV (y -.- x)
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ drawDDATest w =
|
|||||||
<> setLayer DebugLayer (color yellow (line [cvf, mwp]))
|
<> setLayer DebugLayer (color yellow (line [cvf, mwp]))
|
||||||
where
|
where
|
||||||
cvf = w ^. cWorld . lWorld . camPos . camViewFrom
|
cvf = w ^. cWorld . lWorld . camPos . camViewFrom
|
||||||
mwp = mouseWorldPos w
|
mwp = mouseWorldPos (w ^. input) (w ^. cWorld . lWorld . camPos)
|
||||||
--ps = ddaStreamX 50 cvf mwp
|
--ps = ddaStreamX 50 cvf mwp
|
||||||
ps = zoneOfSeg 50 cvf mwp
|
ps = zoneOfSeg 50 cvf mwp
|
||||||
|
|
||||||
@@ -378,7 +378,7 @@ drawMousePosition cfig w =
|
|||||||
$ shortPoint2 mwp
|
$ shortPoint2 mwp
|
||||||
where
|
where
|
||||||
p = worldPosToScreen (w ^. cWorld . lWorld . camPos) mwp
|
p = worldPosToScreen (w ^. cWorld . lWorld . camPos) mwp
|
||||||
mwp = mouseWorldPos w
|
mwp = mouseWorldPos (w ^. input) (w ^. cWorld . lWorld . camPos)
|
||||||
|
|
||||||
drawWlIDs :: Configuration -> World -> Picture
|
drawWlIDs :: Configuration -> World -> Picture
|
||||||
drawWlIDs cfig w = setLayer FixedCoordLayer $ foldMap f (w ^. cWorld . lWorld . walls)
|
drawWlIDs cfig w = setLayer FixedCoordLayer $ foldMap f (w ^. cWorld . lWorld . walls)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ targetDistanceDraw :: Item -> Creature -> Configuration -> World -> Picture
|
|||||||
targetDistanceDraw itm _ cfig w = fromMaybe mempty $ do
|
targetDistanceDraw itm _ cfig w = fromMaybe mempty $ do
|
||||||
p <- itm ^? itTargeting . tgPos . _Just
|
p <- itm ^? itTargeting . tgPos . _Just
|
||||||
let p1 = worldPosToScreen cam p
|
let p1 = worldPosToScreen cam p
|
||||||
mwp = mouseWorldPos w
|
mwp = mouseWorldPos (w ^. input) (w ^. cWorld . lWorld . camPos)
|
||||||
p2 = worldPosToScreen cam mwp
|
p2 = worldPosToScreen cam mwp
|
||||||
thecol = if dist p mwp > 100 then red else white
|
thecol = if dist p mwp > 100 then red else white
|
||||||
return $
|
return $
|
||||||
|
|||||||
+17
-15
@@ -147,7 +147,7 @@ functionalUpdate w =
|
|||||||
checkEndGame
|
checkEndGame
|
||||||
-- . updateRandGen
|
-- . updateRandGen
|
||||||
. over uvWorld (cWorld . lWorld . lClock +~ 1)
|
. over uvWorld (cWorld . lWorld . lClock +~ 1)
|
||||||
. over uvWorld updateWorldSelect
|
. over uvWorld updateWorldSelect'
|
||||||
-- . over uvWorld doRewind
|
-- . over uvWorld doRewind
|
||||||
-- . over uvWorld (hammers . each %~ moveHammerUp)
|
-- . over uvWorld (hammers . each %~ moveHammerUp)
|
||||||
-- . over (uvWorld . hammers . each) moveHammerUp
|
-- . over (uvWorld . hammers . each) moveHammerUp
|
||||||
@@ -248,29 +248,31 @@ zoneClouds w =
|
|||||||
& cWorld . lWorld . clZoning %~ \zn ->
|
& cWorld . lWorld . clZoning %~ \zn ->
|
||||||
foldl' (flip zoneCloud) zn (w ^. cWorld . lWorld . clouds)
|
foldl' (flip zoneCloud) zn (w ^. cWorld . lWorld . clouds)
|
||||||
|
|
||||||
|
updateWorldSelect' :: World -> World
|
||||||
|
updateWorldSelect' w = over input (updateWorldSelect (w ^. cWorld . lWorld . camPos)) w
|
||||||
|
|
||||||
updateWorldSelect :: World -> World
|
updateWorldSelect :: CamPos -> Input -> Input
|
||||||
updateWorldSelect w = f . g $ case (w ^? input . mouseButtons . ix ButtonLeft, w ^? input . mouseButtons . ix ButtonRight) of
|
updateWorldSelect cam inp = f . g $ case (inp ^? mouseButtons . ix ButtonLeft, inp ^? mouseButtons . ix ButtonRight) of
|
||||||
(Just False, Nothing) ->
|
(Just False, Nothing) ->
|
||||||
w & input . lLine . _1 .~ mwp
|
inp & lLine . _1 .~ mwp
|
||||||
& input . lrLine . _1 .~ mwp
|
& lrLine . _1 .~ mwp
|
||||||
(Just True, Nothing) ->
|
(Just True, Nothing) ->
|
||||||
w & input . lLine . _2 .~ mwp
|
inp & lLine . _2 .~ mwp
|
||||||
& input . lrLine . _1 .~ mwp
|
& lrLine . _1 .~ mwp
|
||||||
(Nothing, Just False) ->
|
(Nothing, Just False) ->
|
||||||
w & input . rLine . _1 .~ mwp
|
inp & rLine . _1 .~ mwp
|
||||||
& input . lrLine . _2 .~ mwp
|
& lrLine . _2 .~ mwp
|
||||||
(Nothing, Just True) ->
|
(Nothing, Just True) ->
|
||||||
w & input . rLine . _2 .~ mwp
|
inp & rLine . _2 .~ mwp
|
||||||
& input . lrLine . _2 .~ mwp
|
& lrLine . _2 .~ mwp
|
||||||
_ -> w
|
_ -> inp
|
||||||
where
|
where
|
||||||
mwp = mouseWorldPos w
|
mwp = mouseWorldPos inp cam
|
||||||
f
|
f
|
||||||
| ButtonLeft `M.member` _mouseButtons (_input w) = input . lSelect .~ mwp
|
| ButtonLeft `M.member` _mouseButtons inp = lSelect .~ mwp
|
||||||
| otherwise = id
|
| otherwise = id
|
||||||
g
|
g
|
||||||
| ButtonRight `M.member` _mouseButtons (_input w) = input . rSelect .~ mwp
|
| ButtonRight `M.member` _mouseButtons inp = rSelect .~ mwp
|
||||||
| otherwise = id
|
| otherwise = id
|
||||||
|
|
||||||
--mcChooseUpdate :: Machine -> Machine -> World -> World
|
--mcChooseUpdate :: Machine -> Machine -> World -> World
|
||||||
|
|||||||
@@ -72,4 +72,4 @@ makeFlamerSmokeAt p w = makeCloudAt (CloudColor 4 300 (greyN x)) 6 200 40 p w
|
|||||||
spawnSmokeAtCursor :: World -> World
|
spawnSmokeAtCursor :: World -> World
|
||||||
spawnSmokeAtCursor w = shellTrailCloud (V3 x y 20) w
|
spawnSmokeAtCursor w = shellTrailCloud (V3 x y 20) w
|
||||||
where
|
where
|
||||||
V2 x y = mouseWorldPos w
|
V2 x y = mouseWorldPos (w ^. input) (w ^. cWorld . lWorld . camPos)
|
||||||
|
|||||||
Reference in New Issue
Block a user