Cleanup
This commit is contained in:
@@ -2,7 +2,7 @@ module Dodge.Base.Coordinate (
|
|||||||
cartePosToScreen,
|
cartePosToScreen,
|
||||||
worldPosToScreen,
|
worldPosToScreen,
|
||||||
screenToWorldPos,
|
screenToWorldPos,
|
||||||
mouseWorldPos',
|
mouseWorldPos,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
@@ -37,7 +37,7 @@ coordinates.
|
|||||||
cartePosToScreen :: HUD -> Point2 -> Point2
|
cartePosToScreen :: HUD -> Point2 -> Point2
|
||||||
cartePosToScreen thehud = doRotate . doZoom . doTranslate
|
cartePosToScreen thehud = doRotate . doZoom . doTranslate
|
||||||
where
|
where
|
||||||
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
|
||||||
|
|
||||||
@@ -45,16 +45,13 @@ cartePosToScreen thehud = 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' :: Input -> Camera -> Point2
|
mouseWorldPos :: Input -> Camera -> Point2
|
||||||
mouseWorldPos' inp cam =
|
mouseWorldPos inp cam = screenToWorldPos cam (inp ^. mousePos)
|
||||||
(cam ^. camCenter)
|
|
||||||
+.+ (1 / (cam ^. camZoom)) *.* rotateV (cam ^. camRot) (_mousePos inp)
|
|
||||||
|
|
||||||
|
|
||||||
screenToWorldPos :: Camera -> Point2 -> Point2
|
screenToWorldPos :: Camera -> Point2 -> Point2
|
||||||
screenToWorldPos cam p =
|
screenToWorldPos cam p =
|
||||||
(cam ^. camCenter)
|
(cam ^. camCenter)
|
||||||
+.+ (1 / (cam ^. camZoom)) *.* rotateV (cam ^. camRot) p
|
+ (1 / (cam ^. camZoom)) *.* rotateV (cam ^. camRot) p
|
||||||
|
|
||||||
---- | The mouse position in map coordinates
|
---- | The mouse position in map coordinates
|
||||||
--mouseCartePos :: World -> Point2
|
--mouseCartePos :: World -> Point2
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ applyPiercingDamage cr dm
|
|||||||
/ V2 x x
|
/ V2 x x
|
||||||
x = crMass (_crType cr)
|
x = crMass (_crType cr)
|
||||||
p = _dmPos dm
|
p = _dmPos dm
|
||||||
p1 = p +.+ 2 *.* squashNormalizeV (p -.- _crPos cr)
|
p1 = p + 2 *.* squashNormalizeV (p - _crPos cr)
|
||||||
|
|
||||||
damageHP :: Creature -> Int -> World -> World
|
damageHP :: Creature -> Int -> World -> World
|
||||||
damageHP cr x =
|
damageHP cr x =
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ data EnergyBall = EnergyBall
|
|||||||
{ _ebVel :: Point2
|
{ _ebVel :: Point2
|
||||||
, _ebPos :: Point2
|
, _ebPos :: Point2
|
||||||
, _ebTimer :: Int
|
, _ebTimer :: Int
|
||||||
, _ebEff :: EnergyBallType
|
, _ebType :: EnergyBallType
|
||||||
}
|
}
|
||||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -120,4 +120,4 @@ closestCreatureID u =
|
|||||||
. crsHitRadial mwp 100
|
. crsHitRadial mwp 100
|
||||||
$ _uvWorld u
|
$ _uvWorld u
|
||||||
where
|
where
|
||||||
mwp = mouseWorldPos' (u ^. uvWorld . input) (u ^. uvWorld . wCam)
|
mwp = mouseWorldPos (u ^. uvWorld . input) (u ^. uvWorld . wCam)
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ drawWallsNearYou w = concat $ do
|
|||||||
|
|
||||||
drawWallsNearCursor :: World -> Picture
|
drawWallsNearCursor :: World -> Picture
|
||||||
drawWallsNearCursor w =
|
drawWallsNearCursor w =
|
||||||
foldMap f $ wlsNearPoint (mouseWorldPos' (_input w) (_wCam w)) w
|
foldMap f $ wlsNearPoint (mouseWorldPos (_input w) (_wCam w)) w
|
||||||
where
|
where
|
||||||
f wl =
|
f wl =
|
||||||
setLayer DebugLayer (color rose $ thickLine 3 [a, b])
|
setLayer DebugLayer (color rose $ thickLine 3 [a, b])
|
||||||
@@ -280,7 +280,7 @@ drawZoneNearPointCursor :: World -> Picture
|
|||||||
drawZoneNearPointCursor w =
|
drawZoneNearPointCursor w =
|
||||||
foldMap (drawZoneCol orange 50) ps
|
foldMap (drawZoneCol orange 50) ps
|
||||||
where
|
where
|
||||||
mwp = mouseWorldPos' (w ^. input) (w ^. wCam)
|
mwp = mouseWorldPos (w ^. input) (w ^. wCam)
|
||||||
ps = [zoneOfPoint 50 mwp]
|
ps = [zoneOfPoint 50 mwp]
|
||||||
|
|
||||||
drawDDATest :: World -> Picture
|
drawDDATest :: World -> Picture
|
||||||
@@ -289,7 +289,7 @@ drawDDATest w =
|
|||||||
<> setLayer DebugLayer (color yellow (line [cvf, mwp]))
|
<> setLayer DebugLayer (color yellow (line [cvf, mwp]))
|
||||||
where
|
where
|
||||||
cvf = w ^. wCam . camViewFrom
|
cvf = w ^. wCam . camViewFrom
|
||||||
mwp = mouseWorldPos' (w ^. input) (w ^. wCam)
|
mwp = mouseWorldPos (w ^. input) (w ^. wCam)
|
||||||
ps = zoneOfSeg 50 cvf mwp
|
ps = zoneOfSeg 50 cvf mwp
|
||||||
|
|
||||||
drawWallSearchRays :: World -> Picture
|
drawWallSearchRays :: World -> Picture
|
||||||
@@ -354,7 +354,7 @@ drawMousePosition w =
|
|||||||
. text
|
. text
|
||||||
$ shortPoint2 mwp
|
$ shortPoint2 mwp
|
||||||
where
|
where
|
||||||
mwp = mouseWorldPos' (w ^. input) (w ^. wCam)
|
mwp = mouseWorldPos (w ^. input) (w ^. wCam)
|
||||||
|
|
||||||
drawCoord :: Point2 -> World -> Picture
|
drawCoord :: Point2 -> World -> Picture
|
||||||
drawCoord p w =
|
drawCoord p w =
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ makeFlamelet p v s t w =
|
|||||||
{ _ebVel = v
|
{ _ebVel = v
|
||||||
, _ebPos = p
|
, _ebPos = p
|
||||||
, _ebTimer = t
|
, _ebTimer = t
|
||||||
, _ebEff = FlameletBall s a
|
, _ebType = FlameletBall s a
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
(a, g) = randomR (0, 3) $ _randGen w
|
(a, g) = randomR (0, 3) $ _randGen w
|
||||||
@@ -36,18 +36,18 @@ updateEnergyBall :: World -> EnergyBall -> (World, Maybe EnergyBall)
|
|||||||
updateEnergyBall w eb
|
updateEnergyBall w eb
|
||||||
| _ebTimer eb <= 0 = (w, Nothing)
|
| _ebTimer eb <= 0 = (w, Nothing)
|
||||||
| otherwise =
|
| otherwise =
|
||||||
( ebEffect eb . ebFlicker eb $ ebDamage (_ebPos eb) (_ebEff eb) w
|
( ebEffect eb . ebFlicker eb $ ebDamage (_ebPos eb) (_ebType eb) w
|
||||||
, Just $ eb & ebTimer -~ 1 & ebPos .~ bp & ebVel .~ drag * bv
|
, Just $ eb & ebTimer -~ 1 & ebPos .~ bp & ebVel .~ drag * bv
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
drag = case eb ^. ebEff of
|
drag = case eb ^. ebType of
|
||||||
ExplosiveBall -> 0.9
|
ExplosiveBall -> 0.9
|
||||||
_ -> 0.85
|
_ -> 0.85
|
||||||
p = eb ^. ebPos + eb ^. ebVel
|
p = eb ^. ebPos + eb ^. ebVel
|
||||||
(bp, bv) = fromMaybe (p, eb ^. ebVel) $ bouncePoint (const True) 0 (eb ^. ebPos) p w
|
(bp, bv) = fromMaybe (p, eb ^. ebVel) $ bouncePoint (const True) 0 (eb ^. ebPos) p w
|
||||||
|
|
||||||
ebEffect :: EnergyBall -> World -> World
|
ebEffect :: EnergyBall -> World -> World
|
||||||
ebEffect eb = case _ebEff eb of
|
ebEffect eb = case _ebType eb of
|
||||||
ElectricalBall i ->
|
ElectricalBall i ->
|
||||||
soundContinue (EBSound i) (_ebPos eb) elecCrackleS (Just 2)
|
soundContinue (EBSound i) (_ebPos eb) elecCrackleS (Just 2)
|
||||||
. randSparkExtraVel
|
. randSparkExtraVel
|
||||||
@@ -68,7 +68,7 @@ energyBallAt ebt p =
|
|||||||
{ _ebVel = 0
|
{ _ebVel = 0
|
||||||
, _ebPos = p
|
, _ebPos = p
|
||||||
, _ebTimer = 20
|
, _ebTimer = 20
|
||||||
, _ebEff = ebt
|
, _ebType = ebt
|
||||||
}
|
}
|
||||||
|
|
||||||
makeMovingEB :: Point2 -> EnergyBallType -> Point2 -> World -> World
|
makeMovingEB :: Point2 -> EnergyBallType -> Point2 -> World -> World
|
||||||
@@ -78,7 +78,7 @@ makeMovingEB v ebt p =
|
|||||||
{ _ebVel = v
|
{ _ebVel = v
|
||||||
, _ebPos = p
|
, _ebPos = p
|
||||||
, _ebTimer = 20
|
, _ebTimer = 20
|
||||||
, _ebEff = ebt
|
, _ebType = ebt
|
||||||
}
|
}
|
||||||
|
|
||||||
makeFlashBall :: Point2 -> World -> World
|
makeFlashBall :: Point2 -> World -> World
|
||||||
@@ -92,7 +92,7 @@ ebFlicker pt
|
|||||||
| otherwise = id
|
| otherwise = id
|
||||||
|
|
||||||
ebColor :: EnergyBall -> Color
|
ebColor :: EnergyBall -> Color
|
||||||
ebColor eb = case eb ^. ebEff of
|
ebColor eb = case eb ^. ebType of
|
||||||
IncendiaryBall{} -> red
|
IncendiaryBall{} -> red
|
||||||
FlameletBall{} -> red
|
FlameletBall{} -> red
|
||||||
ElectricalBall{} -> cyan
|
ElectricalBall{} -> cyan
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import Geometry
|
|||||||
import Picture
|
import Picture
|
||||||
|
|
||||||
drawEnergyBall :: EnergyBall -> Picture
|
drawEnergyBall :: EnergyBall -> Picture
|
||||||
drawEnergyBall eb = case _ebEff eb of
|
drawEnergyBall eb = case _ebType eb of
|
||||||
FlameletBall x a -> drawFlamelet x a eb
|
FlameletBall x a -> drawFlamelet x a eb
|
||||||
IncendiaryBall -> drawFlamelet 5 0 eb
|
IncendiaryBall -> drawFlamelet 5 0 eb
|
||||||
ElectricalBall{} -> drawStaticBall eb
|
ElectricalBall{} -> drawStaticBall eb
|
||||||
|
|||||||
+1
-1
@@ -29,7 +29,7 @@ updateFlame w pt
|
|||||||
damageInCircle (const $ Flaming 1) ep r w
|
damageInCircle (const $ Flaming 1) ep r w
|
||||||
thit = List.safeHead $ thingsHit sp ep w
|
thit = List.safeHead $ thingsHit sp ep w
|
||||||
sp = _flPos pt
|
sp = _flPos pt
|
||||||
ep = sp +.+ _flVel pt
|
ep = sp + _flVel pt
|
||||||
mvflame = pt & flTimer -~ 1 & flPos .~ ep & flVel *~ 0.98
|
mvflame = pt & flTimer -~ 1 & flPos .~ ep & flVel *~ 0.98
|
||||||
r = max 0 $ flameSize pt - 1
|
r = max 0 $ flameSize pt - 1
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -304,7 +304,7 @@ functionalUpdate u =
|
|||||||
|
|
||||||
updateAimPos :: Universe -> Universe
|
updateAimPos :: Universe -> Universe
|
||||||
updateAimPos u = u & uvWorld . cWorld . lWorld . lAimPos
|
updateAimPos u = u & uvWorld . cWorld . lWorld . lAimPos
|
||||||
.~ mouseWorldPos' (u ^. uvWorld . input) (u ^. uvWorld . wCam)
|
.~ mouseWorldPos (u ^. uvWorld . input) (u ^. uvWorld . wCam)
|
||||||
|
|
||||||
updateDoor :: Door -> World -> World
|
updateDoor :: Door -> World -> World
|
||||||
updateDoor dr = doDrWdWd (_drMech dr) dr
|
updateDoor dr = doDrWdWd (_drMech dr) dr
|
||||||
|
|||||||
@@ -73,4 +73,4 @@ makeFlamerSmokeAt p w = makeCloudAt (CloudColor 4 300 (greyN x)) 6 200 40 p w
|
|||||||
spawnSmokeAtCursor :: World -> World
|
spawnSmokeAtCursor :: World -> World
|
||||||
spawnSmokeAtCursor w = shellTrailCloud 400 100 (V3 x y 20) w
|
spawnSmokeAtCursor w = shellTrailCloud 400 100 (V3 x y 20) w
|
||||||
where
|
where
|
||||||
V2 x y = mouseWorldPos' (w ^. input) (w ^. wCam)
|
V2 x y = mouseWorldPos (w ^. input) (w ^. wCam)
|
||||||
|
|||||||
Reference in New Issue
Block a user