Zoom in when spawning

This commit is contained in:
2025-12-06 00:04:00 +00:00
parent f9ce58b409
commit 189c3da84f
6 changed files with 75 additions and 72 deletions
+5 -4
View File
@@ -8,6 +8,7 @@ module Dodge.Base.Window (
pointIsOnScreen,
) where
import Linear
import Control.Lens
import Dodge.Data.Camera
import Dodge.Data.Config
@@ -19,9 +20,9 @@ screenPolygon cfig w = map (scTran . scRot . scZoom) $ screenBox cfig
where
scRot = rotateV (w ^. camRot)
scZoom p
| (w ^. camZoom) /= 0 = (1 / (w ^. camZoom)) *.* p
| (w ^. camZoom) /= 0 = (1 / (w ^. camZoom)) *^ p
| otherwise = p
scTran p = p +.+ (w ^. camCenter)
scTran p = p + (w ^. camCenter)
-- | A box covering the screen in world coordinates, with a x and y border
screenPolygonBord ::
@@ -37,9 +38,9 @@ screenPolygonBord xbord ybord cfig w = [tr, tl, bl, br]
hw = halfWidth cfig - xbord
hh = halfHeight cfig - ybord
scZoom p
| (w ^. camZoom) /= 0 = (1 / (w ^. camZoom)) *.* p
| (w ^. camZoom) /= 0 = (1 / (w ^. camZoom)) *^ p
| otherwise = p
theTransform = (+.+ (w ^. camCenter)) . rotateV (w ^. camRot) . scZoom
theTransform = (+ (w ^. camCenter)) . rotateV (w ^. camRot) . scZoom
tr = theTransform (V2 hw hh)
tl = theTransform (V2 (- hw) hh)
br = theTransform (V2 hw (- hh))
+2 -2
View File
@@ -46,9 +46,9 @@ outsideScreenPolygon cfig w = [tr, tl, bl, br]
where
scRot = rotateV (w ^. camRot)
scZoom p
| (w ^. camZoom) /= 0 = (1 / (w ^. camZoom)) *.* p
| (w ^. camZoom) /= 0 = (1 / (w ^. camZoom)) *^ p
| otherwise = error "Trying to set screen zoom to zero"
scTran p = p +.+ (w ^. camCenter)
scTran p = p + (w ^. camCenter)
tr = f 3 3
tl = f (-3) 3
br = f 3 (-3)
+2 -1
View File
@@ -24,7 +24,8 @@ drawMenuScreen mi = \case
drawLoadingScreen :: [String] -> BlockStatus -> Config -> Picture
drawLoadingScreen s _ cfig =
polygon (rectWH (fromIntegral (cfig ^. windowX)) (fromIntegral (cfig ^. windowY)))
<> translateScreenPos
<>
translateScreenPos
cfig
(ScreenPos (V2 0 0.2) (V2 (-300) (10 * fromIntegral (length s))))
(drawList $ map text s)
+2 -1
View File
@@ -13,7 +13,8 @@ respawn w = w & uncurry spawnAt (w ^. cWorld . lWorld . respawnPos)
spawnAt :: Point2 -> Float -> World -> World
spawnAt p d w = w
& wCam . camZoom .~ 1000
& wCam . camZoom .~ 0.000000001
& wCam . camDefaultZoom .~ 0.000000001
& wSoundFilter .~ FilterBySoundOrigin (S.singleton SpawnSound)
-- & cWorld . lWorld . creatures . at 0 %~ (fmap f . (<|> Just startCr))
& cWorld . lWorld . creatures . at 0 ?~ f startCr
+1 -1
View File
@@ -32,7 +32,7 @@ import Data.Foldable
import Data.Monoid
testStringInit :: Universe -> [String]
testStringInit _ = []
testStringInit u = [show $ u^. uvWorld . wCam . camZoom]
-- [show $ foldMap (foldMap (Sum . length . (^. seObstacles)))
-- $ u ^. uvWorld . cWorld . incGraph]
-- foldMap prettyShort $ u ^? uvWorld . cWorld . lWorld . machines . ix 0 . mcType . _McProxSensor